“文档开始”对于 Firefox 插件?
我来自 Chrome 扩展,所以我习惯通过设置 run_at
来定义何时注入文件,例如,在 DOM 构建之前设置为 document_start
进行注入。 Firefox 插件有等效的吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,相当于
content-document-global-created
通知。扩展程序可以为该通知添加观察者,然后对窗口执行某些操作 - 例如注入内容脚本。有关使用此通知的示例,请参阅如何从 Firefox 扩展覆盖 JS 函数?。如果您使用附加 SDK,它会为您完成这项工作。 < code>page-mod 包 支持
contentScriptWhen
参数 - 您可以使用"start"
作为其值,内容脚本将在之前注入任何页面脚本都有机会 跑步。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 acontentScriptWhen
parameter - you can use"start"
as its value and the content script will be injected before any page scripts get a chance to run.