Skip to content

Instantly share code, notes, and snippets.

@au79
Forked from mildmojo/gist:2044883
Created February 9, 2018 17:30
Show Gist options
  • Select an option

  • Save au79/d7ec1b74e9d7df7010b0cda0d6c7561a to your computer and use it in GitHub Desktop.

Select an option

Save au79/d7ec1b74e9d7df7010b0cda0d6c7561a to your computer and use it in GitHub Desktop.
Add Firefox buttons to manipulate about:config settings
/*
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