因此,我在这里关注文档/教程:
https://developer.mozilla.org/zh-CN/Add-ons/SDK/Tutorials/Getting_started
当我使用cfx run时,附件会正确显示,但是当我导出到xpi并在自己的firefox安装中安装时,右上角不会显示任何图标。我已经安装了Firefox版本31,并且安装了不相关的插件,并且其图标显示在右上角的位置,但是我的插件没有。我的加载项在附件管理器的扩展中显示为启用/安装。
我通过他们描述的过程安装了附加组件:
要测试此方法是否有效,请尝试在自己的Firefox安装中安装XPI文件。您可以通过在Firefox中按下Ctrl + O组合键(在Mac上为Cmd + O),或从Firefox的“文件”菜单中选择“打开”项来执行此操作。这将打开一个文件选择对话框:导航到“ my-addon.xpi”文件,将其打开并按照提示安装该附件。
这是我的main.js的代码(按照先前的链接,与cfx run一样工作):
var buttons = require('sdk/ui/button/action');
var tabs = require("sdk/tabs");
var button = buttons.ActionButton({
id: "mozilla-link",
label: "Visit Mozilla",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
"64": "./icon-64.png"
},
onClick: handleClick
});
function handleClick(state) {
tabs.open("http://www.mozilla.org/");
}
启用加载项后,没有收到任何浏览器控制台消息,但是禁用加载项后,我得到以下信息:
Duplicate resource declaration for 'specialpowers' ignored. chrome.manifest:32
Duplicate resource declaration for 'gre-resources' ignored. chrome.manifest:34
Duplicate resource declaration for 'services-sync' ignored. components.manifest:168
Duplicate resource declaration for 'services-common' ignored. components.manifest:170
Duplicate resource declaration for 'services-crypto' ignored. components.manifest:171
Could not read chrome manifest 'file:///C:/Program%20Files%20(x86)/Mozilla%20Firefox/chrome.manifest'.
Duplicate resource declaration for 'pdf.js' ignored. pdfjs.manifest:1
Could not read chrome manifest 'file:///C:/Program%20Files%20(x86)/Mozilla%20Firefox/browser/extensions/%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D/chrome.manifest'.
我遇到了同样的问题,并通过更改package.json
文件以允许插件在私有模式下工作来解决了该问题,请参见此处:https : //developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/private -browsing#Opting_into_private_browsing。我猜它输入时起作用的原因cfx run
是它使用了默认情况下未启用私人浏览的其他配置文件。希望这可以帮助 :)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句