“document_start” for Firefox addon?

走远了吗. 提交于 2020-01-13 18:11:28

问题


I come from Chrome extensions, so I'm used to defining when a file should be injected by setting run_at, e.g., to document_start for injection before DOM construction. Is there an equivalent for Firefox addons?


回答1:


Yes, the equivalent would be the content-document-global-created notification. An extension can add an observer for that notification and then do something with the window - like injecting a content script. See How to override JS function from a firefox extension? for one example of using this notification.

If you use the Add-on SDK it will do this job for you. The page-mod package supports a contentScriptWhen parameter - you can use "start" as its value and the content script will be injected before any page scripts get a chance to run.



来源:https://stackoverflow.com/questions/8744726/document-start-for-firefox-addon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!