Closed modos189 closed 6 years ago
Thanks for reporting. I've filed a bug for this: https://bugzilla.mozilla.org/show_bug.cgi?id=1405026 I currently don't know of any way to get info about the loaded theme.
As long as your icon is static the currently undocumented browser_action.theme_icon key of the manifest should do what you want (especially once https://bugzilla.mozilla.org/show_bug.cgi?id=1404568 lands) Some in-tree doc here: https://hg.mozilla.org/mozilla-central/file/613f64109bde/toolkit/components/extensions/schemas/manifest.json#l352 basically add
"theme_icons": [{
"dark": "icons/undoclosetab.svg",
"light": "icons/undoclosetab-light.svg",
"size": 19
}]
to browser_action
You are right, but the discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1394579#c20 suggests, that there may be a better API in future. The API, you found, is better than nothing, so I'll have a look at this and ship the next version with two SVG icons.
See: https://github.com/M-Reimer/undoclosetab/commit/ff5962fb70119b2da91247581f30bc1d6157ff6a I'll leave this bug open for now, waiting for the resolution of https://bugzilla.mozilla.org/show_bug.cgi?id=1394579#c20 But I can live with the current solution. The second icon is autogenerated by just replacing the "dark" color with white automatically.
I think this API can reply to this issue : https://developer.mozilla.org/fr/Add-ons/WebExtensions/API/browserAction/setIcon
The keys, suggested by @KwanEsq are now officially documented: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/browser_action So I guess we won't see anything better in the near future. As I already use this since a few versions, I'll close this issue now.
Please add a light version of the icon for the dark browser theme. I have chosen the Compact Dark theme and the extension button is very poorly visible