Junk
If your opponent Normal or Special Summons a monster(s): You can change all face-down Defense Position monsters you control to face-up Attack Position. During the End Phase: You can change all monsters you control to face-down Defense Position. You can only use each effect of "Junk Sleep" once per turn.
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--turn faceup
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_POSITION)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_SUMMON_SUCCESS)
	e2:SetProperty(EFFECT_FLAG_DELAY)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1, id)
	e2:SetCondition(s.chcon)
	e2:SetTarget(s.chtg)
	e2:SetOperation(s.chop)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
	c:RegisterEffect(e3)
	--turn facedown
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 1))
	e4:SetCategory(CATEGORY_POSITION)
	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e4:SetCode(EVENT_PHASE + PHASE_END)
	e4:SetRange(LOCATION_SZONE)
	e4:SetCountLimit(1, id + 1)
	e4:SetTarget(s.chtg2)
	e4:SetOperation(s.chop2)
	c:RegisterEffect(e4)
end
function s.filter(c, tp)
	return c:IsSummonPlayer(1 - tp)
end
function s.chcon(e, tp, eg, ep, ev, re, r, rp)
	return eg:IsExists(s.filter, 1, nil, tp)
end
function s.chfilter(c)
	return c:IsFacedown() and c:IsCanChangePosition()
end
function s.chtg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.chfilter, tp, LOCATION_MZONE, 0, 1, nil)
	end
	local g = Duel.GetMatchingGroup(s.chfilter, tp, LOCATION_MZONE, 0, nil)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
end
function s.chop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(s.chfilter, tp, LOCATION_MZONE, 0, nil)
	if g:GetCount() > 0 then
		Duel.ChangePosition(g, POS_FACEUP_ATTACK)
	end
end
function s.chtg2(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(Card.IsCanTurnSet, tp, LOCATION_MZONE, 0, 1, nil)
	end
	local g = Duel.GetMatchingGroup(Card.IsCanTurnSet, tp, LOCATION_MZONE, 0, nil)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
end
function s.chop2(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(Card.IsCanTurnSet, tp, LOCATION_MZONE, 0, nil)
	if g:GetCount() > 0 then
		Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
	end
end


Junk
If your opponent Normal or Special Summons a monster(s): You can change all face-down Defense Position monsters you control to face-up Attack Position. During the End Phase: You can change all monsters you control to face-down Defense Position. You can only use each effect of "Junk Sleep" once per turn.
-- Junk
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	c:RegisterEffect(e1)
	--turn faceup
	local e2 = Effect.CreateEffect(c)
	e2:SetDescription(aux.Stringid(id, 0))
	e2:SetCategory(CATEGORY_POSITION)
	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e2:SetCode(EVENT_SUMMON_SUCCESS)
	e2:SetProperty(EFFECT_FLAG_DELAY)
	e2:SetRange(LOCATION_SZONE)
	e2:SetCountLimit(1, id)
	e2:SetCondition(s.chcon)
	e2:SetTarget(s.chtg)
	e2:SetOperation(s.chop)
	c:RegisterEffect(e2)
	local e3 = e2:Clone()
	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
	c:RegisterEffect(e3)
	--turn facedown
	local e4 = Effect.CreateEffect(c)
	e4:SetDescription(aux.Stringid(id, 1))
	e4:SetCategory(CATEGORY_POSITION)
	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
	e4:SetCode(EVENT_PHASE + PHASE_END)
	e4:SetRange(LOCATION_SZONE)
	e4:SetCountLimit(1, id + 1)
	e4:SetTarget(s.chtg2)
	e4:SetOperation(s.chop2)
	c:RegisterEffect(e4)
end
function s.filter(c, tp)
	return c:IsSummonPlayer(1 - tp)
end
function s.chcon(e, tp, eg, ep, ev, re, r, rp)
	return eg:IsExists(s.filter, 1, nil, tp)
end
function s.chfilter(c)
	return c:IsFacedown() and c:IsCanChangePosition()
end
function s.chtg(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(s.chfilter, tp, LOCATION_MZONE, 0, 1, nil)
	end
	local g = Duel.GetMatchingGroup(s.chfilter, tp, LOCATION_MZONE, 0, nil)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
end
function s.chop(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(s.chfilter, tp, LOCATION_MZONE, 0, nil)
	if g:GetCount() > 0 then
		Duel.ChangePosition(g, POS_FACEUP_ATTACK)
	end
end
function s.chtg2(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.IsExistingMatchingCard(Card.IsCanTurnSet, tp, LOCATION_MZONE, 0, 1, nil)
	end
	local g = Duel.GetMatchingGroup(Card.IsCanTurnSet, tp, LOCATION_MZONE, 0, nil)
	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
end
function s.chop2(e, tp, eg, ep, ev, re, r, rp)
	local g = Duel.GetMatchingGroup(Card.IsCanTurnSet, tp, LOCATION_MZONE, 0, nil)
	if g:GetCount() > 0 then
		Duel.ChangePosition(g, POS_FACEDOWN_DEFENSE)
	end
end

