JavaScript - how greasemonkey works

I read The Immersion in Greasemonkey ( Mark Pilgrim ), written in 2005. He mentions that Greasemonkey wraps the user script in an anonymous function shell. Does Greasemonkey include a wrapper in the JavaScript source code, or adds it like any other event handler, such as window.onload ?

+7
javascript google-chrome-extension greasemonkey firefox-addon
source share
1 answer

Does Greasemonkey include a wrapper in the JavaScript source code, or add it like any event handler like window.onload?

GM listens for the DOMContentLoaded event (mostly DOM Ready) here . Then it completes the usercript code and inserts it into the sandbox here .

+6
source share

All Articles