如何让我的图标显示在我的 Firefox Addon 中?
How to get my icon to display in my Firefox Addon?
我创建了一个插件并将其上传到 addons.mozilla.org,它工作正常,但它显示的是默认图标而不是我的图标。 Chrome.
没有这个问题
我的 manifest.json
文件如下所示:
{
"manifest_version": 2,
"name": "Handcash handle converter",
"version": "1.4",
"description": "Get a receiving address for a Handcash $handle",
"icons": {
"48": "handcash48.png",
"64": "handcash64.png",
"128": "handcash128.png"
},
"browser_action": {
"default_title": "Handcash handle converter",
"default_popup": "./popup/popup.html"
},
"homepage_url": "https://www.handcash.io",
"short_name": "HandcashConv",
"content_security_policy": "script-src 'self' https://api.moneybutton.com ; object-src 'self'",
"permissions": [
"storage",
"clipboardWrite"
]
}
我尝试将图标放在它们自己的目录和扩展程序的根目录中,但没有成功。扩展在 Firefox 中看起来像这样:
如果您感兴趣,请查看完整源代码:https://github.com/markallisongit/handcash-chrome
manifest.json
的icons
入口指的是插件列表、插件管理页面等使用的图标,这里要设置的是browserAction
的图标工具栏中的按钮。如果您查看 MDN 上的 browser_action 页面,您会注意到一个 default_icon
设置,我相信这就是您要查找的内容:
Use this to specify one or more icons for the browser action. The icon
is shown in the browser toolbar by default.
Icons are specified as URLs relative to the manifest.json file itself.
You can specify a single icon file by supplying a string here:
"default_icon": "path/to/geo.svg"
To specify multiple icons in different sizes, specify an object here.
The name of each property is the icon's height in pixels, and must be
convertible to an integer. The value is the URL. For example:
"default_icon": {
"16": "path/to/geo-16.png",
"32": "path/to/geo-32.png"
}
最后,您应该更新 manifest.json 以便它包含此 default_icon
设置,如下所示:
{
"manifest_version": 2,
"name": "Handcash handle converter",
...
"browser_action": {
"default_title": "Handcash handle converter",
"default_popup": "./popup/popup.html",
"default_icon": {
"48": "handcash48.png",
"64": "handcash64.png",
"128": "handcash128.png"
}
},
...
}
我创建了一个插件并将其上传到 addons.mozilla.org,它工作正常,但它显示的是默认图标而不是我的图标。 Chrome.
没有这个问题我的 manifest.json
文件如下所示:
{
"manifest_version": 2,
"name": "Handcash handle converter",
"version": "1.4",
"description": "Get a receiving address for a Handcash $handle",
"icons": {
"48": "handcash48.png",
"64": "handcash64.png",
"128": "handcash128.png"
},
"browser_action": {
"default_title": "Handcash handle converter",
"default_popup": "./popup/popup.html"
},
"homepage_url": "https://www.handcash.io",
"short_name": "HandcashConv",
"content_security_policy": "script-src 'self' https://api.moneybutton.com ; object-src 'self'",
"permissions": [
"storage",
"clipboardWrite"
]
}
我尝试将图标放在它们自己的目录和扩展程序的根目录中,但没有成功。扩展在 Firefox 中看起来像这样:
如果您感兴趣,请查看完整源代码:https://github.com/markallisongit/handcash-chrome
manifest.json
的icons
入口指的是插件列表、插件管理页面等使用的图标,这里要设置的是browserAction
的图标工具栏中的按钮。如果您查看 MDN 上的 browser_action 页面,您会注意到一个 default_icon
设置,我相信这就是您要查找的内容:
Use this to specify one or more icons for the browser action. The icon is shown in the browser toolbar by default.
Icons are specified as URLs relative to the manifest.json file itself.
You can specify a single icon file by supplying a string here:
"default_icon": "path/to/geo.svg"
To specify multiple icons in different sizes, specify an object here. The name of each property is the icon's height in pixels, and must be convertible to an integer. The value is the URL. For example:
"default_icon": { "16": "path/to/geo-16.png", "32": "path/to/geo-32.png" }
最后,您应该更新 manifest.json 以便它包含此 default_icon
设置,如下所示:
{
"manifest_version": 2,
"name": "Handcash handle converter",
...
"browser_action": {
"default_title": "Handcash handle converter",
"default_popup": "./popup/popup.html",
"default_icon": {
"48": "handcash48.png",
"64": "handcash64.png",
"128": "handcash128.png"
}
},
...
}