Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// 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