将后台脚本添加到Firefox附加组件 [英] Adding background scripts to a firefox add-on

查看:154
本文介绍了将后台脚本添加到Firefox附加组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



$ p $ 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文件中。


b


除了与Web内容直接交互的脚本外,使用SDK开发附加组件时所用的所有JavaScript代码都是CommonJS模块的一部分。


实质上,后端脚本不共享像内容脚本/普通JS这样的变量。你 export require 模块之间的变量。



请参阅添加本地模块


I want to add a file(background.js) which is a background script for my firefox extension. I added content scripts to my main.js using the following code.

 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")]
});

How do I add background scripts to the main.js file.

解决方案

Simply place the file in the lib folder.

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.

Essentially, backend script don't share variables like content scripts/normal JS. You export and require variables between modules.

See adding local modules

这篇关于将后台脚本添加到Firefox附加组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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