[Greasemonkey] accessing js functions outside of GM scope
Lenny Domnitser
ldrhcp at gmail.com
Thu Apr 6 17:41:45 EDT 2006
On 4/6/06, Chris McKeever <techjedi at gmail.com> wrote:
> Is it possible to make calls to functions which are outside the scope
> of the GM functions?
> I have been trying with no avail. Taking that one step further - is
> it then possible to inject js functionality into those functions, or
> even just overide them addding a new function (similiar to
> http://diveintogreasemonkey.org/patterns/override-method.html)
There is a function called GM_executeContentScript in Greasemonkey's
CVS, that does this. You can use it for now by just copying it into
your script from miscapis.js [1]. Then call it like so:
GM_executeContentScript(function() {
// run code in a bookmarklet context, such as:
window.functionToOverride = function() { ... };
});
Mark actually asked about this for the upcoming version of Dive Into
Greasemonkey [2], so presumably the link you provided will eventually
be updated to reflect this method.
BTW, Aaron: is the function going to be in the next release?
[1]: http://www.mozdev.org/source/browse/greasemonkey/src/chrome/chromeFiles/content/miscapis.js
[2]: http://thread.gmane.org/gmane.comp.mozilla.firefox.greasemonkey/7569
More information about the Greasemonkey
mailing list