Making a Firefox addon that creates a simple toggle button that can switch a setting on and off

I want to create a simple button that when pressed, changes the value of the setting browser.display.document_color_use to 1, and when pressed a second time is changed back to 2.

I have no idea where to even begin. I really hope somebody can help me

Depending where your knowledge is at, you may want to start at https://developer.mozilla.org/en-US/Add-ons/WebExtensions/What_are_WebExtensions

The specific APIs you’d want to use are


and
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/theme most likely. Or the content scripts API. I don’t think you can toggle the actual pref (as in, it’s not exposed) though. (Maybe yet?)

1 Like

Thanks for the links!

I still have no idea how to achieve the desired results without changing that specific setting, though. Hmm. Also, I am not a programmer so most of this stuff is like Chinese to me! :slight_smile:

Starting at the first link seems like a good idea then, or maybe even at the MDN JS/CSS/HTML intros.

The problem is finding the “function” to either influence the setting browser.display.document_color_use or do something that achieves the same effect.
It’s basically just the toggle between “Always” and “Never” when forcing your own color scheme onto webpages you visit. (For example this webpage is horribly white and bright and burns two holes straight through my skull)

Is there anywhere you can request API support for certain preferences?

See here https://wiki.mozilla.org/WebExtensions/NewAPIs