Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created January 30, 2011 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Constellation/803115 to your computer and use it in GitHub Desktop.
Save Constellation/803115 to your computer and use it in GitHub Desktop.
// GM window to be shared patch
// 2011/01/31 id:Constellation
{
let gm = Components.classes['@greasemonkey.mozdev.org/greasemonkey-service;1'];
if (gm) {
gm = gm.getService().wrappedJSObject;
let evalInSandbox = gm.evalInSandbox;
addAround(gm, 'injectScripts', function(proceed, args) {
let shared = args[2];
addAround(gm, 'evalInSandbox', function(proceed, args) {
let sandbox = args[1];
sandbox.sharedWindow = shared;
sandbox.__proto__ = shared;
args[0] = '(function(window, document) {\n' + args[0] + '\n})(sharedWindow, sharedWindow.document)';
return proceed(args);
});
let res = proceed(args);
gm.evalInSandbox = evalInSandbox;
return res;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment