firefox - 将后台脚本添加到 firefox 插件

标签 firefox firefox-addon firefox-addon-sdk

我想添加一个文件(background.js),它是我的 firefox 扩展的后台脚本。
我使用以下代码将内容脚本添加到我的 main.js。

 var panel = panels.Panel({
   contentURL: self.data.url("panel.html"),
   onHide: handleHide,
   contentScriptFile: [self.data.url("js/jquery.js"), 
                  self.data.url("tipsy/jquery.tipsy.js"),,
                  self.data.url("js/settings.js")]
});

如何将后台脚本添加到 main.js 文件。

最佳答案

只需将文件放在 lib文件夹。

Except for scripts that interact directly with web content, all the JavaScript code you'll write or use when developing add-ons using the SDK is part of a CommonJS module.



本质上,后端脚本不共享内容脚本/普通 JS 等变量。你 exportrequire模块之间的变量。

adding local modules

关于firefox - 将后台脚本添加到 firefox 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27243403/

相关文章:

jquery animate(高度)导致背景图像在 Firefox 中闪烁

javascript: namespace 污染

javascript - 如何从 Firefox 扩展/插件向任何页面动态添加 div 元素

firefox - 单击小部件图标后如何显示菜单?

css - Firefox 动画不启动切换显示样式

javascript - object.style.zoom 属性在 Firefox 中不起作用

html - 如何在 Firefox 上使用 css 使伪元素可见和可点击

javascript - elt.lang = 'fr' 不工作

firefox-addon - 如何在引导的 Firefox 扩展中实现 XPCOM 组件(nsIContentPolicy)

javascript - pageMod 多次附加 worker