【问题标题】:Adding background scripts to a firefox add-on将后台脚本添加到 firefox 插件
【发布时间】:2014-12-02 06:45:08
【问题描述】:

我想添加一个文件(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 文件。

【问题讨论】:

    标签: firefox firefox-addon firefox-addon-sdk


    【解决方案1】:

    只需将文件放在lib 文件夹中即可。

    除了直接与网页内容交互的脚本外,您在使用 SDK 开发插件时编写或使用的所有 JavaScript 代码都是 CommonJS 模块的一部分。

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

    adding local modules

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多