-
-
Save au79/d7ec1b74e9d7df7010b0cda0d6c7561a to your computer and use it in GitHub Desktop.
Add Firefox buttons to manipulate about:config settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| I needed a button in the Firefox UI to toggle the default page zoom level | |
| setting offered by the NoSquint extension (shown as "extensions.nosquint.fullZoomLevel" | |
| in about:config). Since this isn't likely to be provided directly and I | |
| wasn't interested in writing my own extension for something so simple, I | |
| looked for an extension that would expose about:config settings to buttons. | |
| Instead, I found the Custom Buttons extension: | |
| https://addons.mozilla.org/en-US/firefox/addon/custom-buttons/ | |
| Custom Buttons lets you put some javascript behind a button that can be | |
| placed on your toolbars. The code operates as a XUL overlay, so you have | |
| access to Firefox's internal APIs. Here's the code I used: | |
| */ | |
| var prefManager = Components.classes["@mozilla.org/preferences-service;1"] | |
| .getService(Components.interfaces.nsIPrefBranch); | |
| // Available methods: getIntPref, getBoolPref, getCharPref | |
| var currentZoom = prefManager.getIntPref( "extensions.nosquint.fullZoomLevel" ); | |
| if ( currentZoom < 150 ) { | |
| currentZoom = 150; | |
| } else { | |
| currentZoom = 100; | |
| } | |
| // Available methods: setIntPref, setBoolPref, setCharPref available | |
| prefManager.setIntPref( "extensions.nosquint.fullZoomLevel", currentZoom ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment