do the unsafeWindow/window shimmy sham

if run from greasemonkey use window.wrappedJSObject (aka unsafeWindow). also some little touch ups.