Glen Little
Glen Little

Reputation: 7128

How to detect Firefox Theme

For a WebExtension, we use browser.browserAction.setIcon to set the icon. As you can see in this sample, to fit in, the icon should have a dark or light background.

How can my Javascript code know which theme is in effect? Or better, can I determine what the background color for the toolbar is so I can make an appropriate icon?

enter image description here

Upvotes: 5

Views: 661

Answers (1)

Santosh
Santosh

Reputation: 2333

You can use the theme javascript api listed in webextensions to get theme details. Please make sure you add "theme" permission in your manifest.json file.

Upvotes: 2

Related Questions