Felix Crux

Technology & Miscellanea

Tags: ,

Firefox already has an excellent cloud-based Sync system for sharing settings and browser history between computers — but perhaps you don’t want any of your data stored on remote servers; or you keep separate work and personal profiles; or you don’t want to have to set it up in several places (like short-lived virtual machines); or maybe you just like to keep all your settings in plain text files you can copy around.

I fall into several of those categories, but until recently, I didn’t know Firefox had a built-in solution.

In addition to the more well-known userChrome.css and userContent.css files (which can be used to control, respectively, the appearance of the browser itself and the styling of pages you visit), Firefox also has a user.js file to define personal preferences and settings. Anything exposed in the UI, or via the special about:config page, can be set from here — and, crucially, shared to different machines or profiles, without needing to click through the UI to reconfigure anything.

The only tricky part is finding the name of the setting you want. Most options are documented on this wiki page of about:config entries, but if it’s not there, a bit of hunting in the about:config page, or of searching online, usually reveals what you need. Then, simply create a file named user.js in the root of your Firefox profile directory (which, on Linux, looks something like ~/.mozilla/firefox/<randomname>.default/), and put a line like this in it:


user_pref("name.of.setting", value);

You can also use this mechanism to save and share settings that aren't exposed in the Preferences UI, without needing to remember and set cryptic keywords in the about:config page.

For example, to enable Firefox’s built-in tracking protection all the time, even when not in Private Browsing mode (which you can’t yet do through the GUI!), include this snippet:


// Use Tracking Protection mode everywhere, not just in Private Browsing
user_pref("privacy.trackingprotection.enabled", true);

Or, to permanently clear out the junk that gets added at the top and bottom of every page you print out (like date & time, page number, etc.), set all of print.print_headerleft, print.print_headercenter, print.print_headerright, print.print_footerleft, print.print_footercenter, and print.print_footerright to the empty string: "".

For more ideas and examples, have a look at my user.js file.


blog comments powered by Disqus