" document_start"为Firefox插件? [英] "document_start" for Firefox addon?

查看:147
本文介绍了" document_start"为Firefox插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自Chrome扩展程序,因此我习惯于通过设置 run_at 来定义何时注入文件,例如 document_start 用于DOM构建之前的注入。是否有相当于Firefox的插件?

解决方案

是的,相当于是 content-document-global-created notification 。一个扩展可以为该通知添加一个观察者,然后对该窗口执行一些操作 - 就像注入一个内容脚本一样。有关使用此通知的一个示例,请参阅如何从Firefox扩展中重写JS函数?

如果您使用附加SDK,它将为您完成这项工作。 page-mod package 支持 contentScriptWhen 参数 - 您可以使用start 作为它的值,内容脚本将在任何页面脚本有机会运行之前被注入。


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?

解决方案

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.

这篇关于" document_start"为Firefox插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆