I read "Dive into Greasemonkey" (by Mark Pilgrim) written in 2005. It mentions that Greasemonkey wraps a user script in an anonymous function w开发者_如何学编程rapper. Does Greasemonkey insert the wrapper into the source JavaScript code or add it as any event handler such as window.onload
?
Does Greasemonkey insert the wrapper into the source JavaScript code or add it as any event handler such as window.onload?
GM listens to DOMContentLoaded event (basically DOM Ready) here. Then wraps the userscript code and inserts that into a sandbox, here.
精彩评论