This should work, but I don't have the perk so I can't test it. You need an addon that'll loop macros if you want it to be automated.
Code:
/run if UnitIsDead('player')==1 then if TimeL==nil then TimeL=GetTime() Logout() end end
/run if TimeL~=nil then if GetTime()-TimeL > 1 then AcceptResurrect() end end
/run if TimeL~=nil then if GetTime()-TimeL > 2 then RunMacroText("/click StaticPopup1Button1") TimeL=nil end end
If it doesn't work tell me what it doesn't do or does do, and I'll fix it.
Edit: Changed macro since apparently CancelLogout() is hard protected, removed, or falls under a different protection offset.