我正在尝试为 Firefox 编写插件。为此,我使用 Mozilla“Addon-SDK”。
当我使用“jpm run”功能时一切正常。但是一旦我将它打包到 xpi 并安装它,该图标就不会显示在工具栏中。这似乎是 SDK 中的错误。
我尝试了其他博客文章中的各种变通解决方案。
- 编辑 package.json
- 重命名为“图标”
- 转向数据
- 将图标移动到根
- 绝对路径
- 在 rdf 中编辑 firefox 版本
- 调试 Index.js...
这里最有用:
Firefox add-on : extension icon not showing
https://github.com/mozilla-jetpack/jpm/issues/197
因为 Firefox 43 插件必须经过验证。我这样做了。我还在 about:config 中禁用了该功能,因此我可以更快地尝试新版本。仍然没有运气。
这是我在 index.js 中的代码:根据答案进行了编辑,但仍然无法正常工作
var button = buttons.ActionButton(
{
id: "MorastLink",
label: "In den Morast",
icon:
{
"16": "./images/icon16.png",
"32": "./images/icon32.png",
"64": "./images/icon64.png"
},
onClick: CopyToMorast
});
这里我也试过了,移动路径,改名,使用绝对路径...
这是我的package.json
{
"title": "Morast",
"name": "morastaddon",
"version": "0.1.4",
"description": "An Addon to insert a \"Add to Morast\" button on distributer sites.",
"main": "index.js",
"author": "Lisa Austen",
"icon": "ressource://@morastaddon/data/images/icon16.png",
"icon64": "ressource://@morastaddon/data/images/icon64.png",
"engines": {
"firefox": ">=38.0a1",
"fennec": ">=38.0a1" },
"license": "MIT",
"keywords": [
"jetpack"
]
}
最佳答案
根据 MDN ,图标路径必须相对于 data
文件夹:
as a resource:// URL pointing at an icon file in your add-on's "data" directory, typically constructed using self.data.url(iconfile)
as a relative path: a string in the form "./iconfile", where "iconfile" is a relative path to the icon file beginning in your add-on's "data" directory
例子:
icon:
{
"16": "./images/icon16.png",
"32": "./images/icon32.png",
"64": "./images/icon64.png"
}
关于javascript - Firefox 插件 - 图标不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34768273/