当 Firefox 启动时启动 Firefox 扩展
我编写了一个 Firefox 扩展来处理响应和请求。现在,通过单击菜单按钮即可激活它。我希望扩展程序在 Firefox 启动时开始运行。这可能吗?理想情况下,我想要/需要的唯一界面是在附加管理器内(禁用/卸载)
谢谢
I wrote a firefox extension to process response and requests. Right now its activated by clicking a menu button. I would like the extension to start running when firefox boots up. Is this possible? Ideally the only interface I want/need to have is inside the add-on manager (disable/uninstall)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,在清单文件中的
browser.xul
上注册覆盖:然后,在
sample.xul
中包含一些 JavaScript。此 JavaScript 应将onload
事件处理程序附加到窗口。每次打开新的浏览器窗口并且您的代码将运行时,都会触发此操作。或者,如果您只需要在所有窗口之间共享代码的一个实例,请考虑使用成熟的 XPCOM 组件,您可以在其中注册监听
profile-after-change
事件,这是在建立配置文件目录和其他服务之后启动时发生的最早事件之一。First, register an overlay on
browser.xul
in your manifest file:Then, include some JavaScript in your
sample.xul
. This JavaScript should attach anonload
event handler to the window. This will fire every time a new browser window is opened and your code will run.Alternatively, if you need just one instance of your code to be shared among all windows, consider a full-blown XPCOM component, in which you can register to listen for the
profile-after-change
event, which is one of the earliest events that occurs on startup, after the profile directory and other services have been established.