“文档开始”对于 Firefox 插件?

发布于 2024-12-25 05:16:21 字数 128 浏览 2 评论 0原文

我来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事还在继续 2025-01-01 05:16:21

是的,相当于 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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文