Hello
I’m working on my extension and faced with a problem, hope you will help to resolve it.
My addon has 3 icons:
- Main icon - green color. It’s the main icon that represents the logo of my addon and is also used as a logo on
about:addons
page - Light icon - white color, will be used as an action icon for users with a dark theme
- Dark icon - black color, will be used as an action icon for users with a light theme
all icons are the same, there just a color difference
All of them are used in the manifest file in the next way. I don’t post full manifest, if needed I could do it in the comment
"manifest_version": 2,
...
"icons": {
"16": "icons/main/16.png",
"48": "icons/main/48.png",
}
...
"browser_action": {
...
"default_icon": {
"16": "icons/light/16.png",
"48": "icons/light/48.png",
},
"theme_icons": [
{
"light": "icons/light/16.png",
"dark": "icons/dark/16.png",
"size": 16
},
{
"light": "icons/light/48.png",
"dark": "icons/dark/48.png",
"size": 48
},
]
},
...
theme in the browser could be dark or light but only a light icon will be used immediately after installing the addon. As it is set in browser_action.default_icon
property. it doesn’t matter what theme is right now in user’s browser.
if I remove browser_action.default_icon
then the “icons” field starts using as a default icon source (with the main green icon).
If the user tries to change his theme, then the correct icon is selected from browser_action.theme_icons
array (dark or light).
Is there any way to select the correct icon without additional JS? (browser.runtime.onInstalled event)
As for me it looks like a bug and has incorrect behavior. I think if default_icon
is not present, then theme_icons
should be used based on the browser theme or OS if theme-auto is selected not icons
.