Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 499
Glen Little Avatar asked Oct 30 '22 03:10

Glen Little


1 Answers

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.

like image 70
Santosh Avatar answered Nov 04 '22 09:11

Santosh