开发者

JavaScript - how Greasemonkey works

开发者 https://www.devze.com 2023-01-07 08:36 出处:网络
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 w

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号