In Safari I normally have a Macro Palette open, but if Safari is in fullscreen mode ( when viewing videos on YouTube, etc.) I don't want to see the Palette. This macro shows or hides the Palette when Safari switches to and from fullscreen.
and if there were any risk of an error condition (Safari not running, or running but no windows open, for example), you could write something slightly more defensive: