Skip to content

Instantly share code, notes, and snippets.

@atomer
Last active September 26, 2015 03:37
Show Gist options
  • Save atomer/1032908 to your computer and use it in GitHub Desktop.
Save atomer/1032908 to your computer and use it in GitHub Desktop.
http://d.hatena.ne.jp/os0x/20090824/1251133041 にほんの少し手を加えた、UserScriptでwindowを取得するスニペット
(function(window, loaded){
var win;
if (!loaded && this.chrome) {
var fn = '(' + arguments.callee.toString() + ')(this,true);';
var script = document.createElement('script');
script.appendChild(document.createTextNode(fn));
document.body.appendChild(script);
return;
} else if (this.chrome) {
win = window;
} else {
win = unsafeWindow;
}
})(window);
((window, loaded) ->
if not loaded and @chrome
fn = '(' + arguments.callee.toString() + ')(this,true);'
script = document.createElement('script')
script.appendChild(document.createTextNode(fn))
document.body.appendChild(script)
return
else if @chrome
win = window
else
win = unsafeWindow
)(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment