Firefox SDK示例添加导出的XPI操作按钮不显示 [英] Firefox SDK Sample Add On Exported XPI Action Button Doesn't Show Up

查看:132
本文介绍了Firefox SDK示例添加导出的XPI操作按钮不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在这里按照文档/教程:

https://developer.mozilla.org/zh-CN/Add-ons/SDK/Tutorials/Getting_started



当我使用cfx运行时,添加显示正确,但是当我导出到xpi并在我自己安装的Firefox上安装时,没有图标显示在右上角。我安装了Firefox版本31,并且安装了一个无关的添加,它的图标显示了它应该在右上角的位置,但是我的附加组件没有。我的附加功能显示为在附加组件管理器中的扩展功能启用/安装。



我通过他们描述的过程安装了我的附加组件:


为了测试这个工作,尝试在您自己的
Firefox安装中安装XPI文件。您可以通过在Firefox中按Ctrl + O键
组合(Mac上的Cmd + O),或从Firefox的文件菜单中选择
打开项来执行此操作。这将弹出一个文件
选择对话框:导航到my-addon.xpi文件,打开它并
按照提示安装附加组件。


这里是我的main.js代码(按照前面的链接,按照预期的方式运行cfx):

  var buttons = require('sdk / ui / button / action'); 
var tabs = require(sdk / tabs);

var button = buttons.ActionButton({
id:mozilla-link,
label:访问Mozilla,
图标:{
16:./icon-16.png,
32:./icon-32.png,
64:./icon-64.png
},
onClick:handleClick
});

函数handleClick(状态){
tabs.open(http://www.mozilla.org/);
}

启用加载项后,我没有收到任何浏览器控制台消息,当我禁用附加组件时,我得到以下结果:

 忽略'specialpowers'的重复资源声明。 chrome.manifest:32 
忽略gre-resources的重复资源声明。 chrome.manifest:34
services-sync的重复资源声明被忽略。 components.manifest:168
services-common的重复资源声明被忽略。 components.manifest:170
'services-crypto'的重复资源声明被忽略。 components.manifest:171
无法读取chrome清单文件:/// C:/ Program%20Files%20(x86)/Mozilla%20Firefox/chrome.manifest'。
忽略pdf.js的重复资源声明。 pdfjs.manifest:1
无法读取chrome清单文件:/// C:/ Program%20Files%20(x86)/ Mozilla%20Firefox / browser / extensions /%7B972ce4c6-7e08-4474-a285-3208198ce6fd %7D / chrome.manifest用于。


解决方案

我有同样的问题, package.json 文件允许插件在私有模式下工作,请看这里: https://developer.mozilla.org/zh-CN/Add-ons/SDK/High-Level_APIs/private-browsing#Opting_into_private_browsing 。我猜你输入 cfx run 的原因是它使用了一个不同的配置文件,默认情况下它没有启用隐私浏览功能。希望这有助于:)


So I am following the documentation/tutorial here:

https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_started

The add on shows up correctly when I use cfx run but when I export to xpi and install on my own installation of firefox no icon shows up in the top right corner. I have Firefox version 31 installed and have an unrelated add on installed and its icon shows up where it should in the top right corner but my add on does not. My add on shows up as enable / installed under Extensions in the Add-ons Manager.

I installed my add on through the process they described:

To test that this worked, try installing the XPI file in your own Firefox installation. You can do this by pressing the Ctrl+O key combination (Cmd+O on Mac) from within Firefox, or selecting the "Open" item from Firefox's "File" menu. This will bring up a file selection dialog: navigate to the "my-addon.xpi" file, open it and follow the prompts to install the add-on.

Here is the code for my main.js (as per previous link, which works as expected with 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/");
}

I don't get any browser console messages upon enabling the add-on but when I disable the add-on I get the following:

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'.

解决方案

I had the same problem and solved it by changing the package.json file to allow the addon working in the private mode, see here: https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/private-browsing#Opting_into_private_browsing . I guess the reason it works when you type cfx run is that it uses a different profile that has not enabled private browsing by default. Hope this helps :)

这篇关于Firefox SDK示例添加导出的XPI操作按钮不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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