Setting the Default Firefox Homepage with Autoconfig
Recently I've seen a lot of questions around why defaultPref in an autoconfig file doesn't work to set the Firefox hompage. For example this:
defaultPref("browser.startup.homepage", "http://mike.kaply.com");
does not work.
This post should clear things up (and show you how to make it work).
So unique about the browser.startup.homepage preference that it's default values cannot be set like other preferences in the autoconfig file>
It is a complex preference.
Complex preferences are preferences whose default value is a pointer to a properties file that contains the value of the preference. Although when you go to about:config and search on browser.startup.homepage and see about:home as the value, that is not the true value of browser.startup.homepage. To see the true value, we can look in the configuration file for Firefox:
pref("browser.startup.homepage", "chrome://branding/locale/browserconfig.properties");
From there, we can look in browserconfig.properties to see the value:
browser.startup.homepage=about:home
So why is the browser homepage a complex preference? Complex preferences are used when you want to be able to translate a preference value. In the past, the Firefox homepage was localizable; that's why it ended up being a complex preference.
You need to be aware of all of the complex preferences in Firefox because if you want to set the default value of any of them, you'll need to follow the instructions I'll give later in this post. The complex preferences you'll probably care about are:
browser.startup.homepage browser.search.defaultenginename browser.search.order.1 browser.search.order.2 browser.search.order.3
There are some other ones in firefox.js, but these are the important ones.
So here is the million dollar question; how do you set the default value for these preferences?
You can use a data URL to fake the complex preference behavior:
defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://mike.kaply.com");
And that's how you set the default value of the Firefox homepage with autoconfig.
don't teach people to do that.. we need less of it, not more!
You'll get to see the whole data: URL in about:config as it only does the complex value trick for chrome locale properties files.
Hello.
I've tried to do what you tell in this entry of this amazing blog, but without success. Would you tell me what I'm doing wrong, please?
I'm running Ubuntu 12.04 with Firefox 13. I've created the file /usr/lib/firefox/defaults/pref/hello.js with the line
pref("general.config.file", "firefox.cfg");
and I've created the file /usr/lib/firefox/defaults/pref/firefox.cfg
with the lines
//BLANK LINE
defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://mike.kaply.com");
But when I start Firefox, it remains the same homepage it had before (in other words, these changes doesn't work). I've tried creating a new user to see if these configurations work in a new and clean user, but it doesn't.
Please, please, please. What I'm doing wrong??
Thanks, thanks, thanks!!
I've also tried locating firefox.cfg in /usr/lib/firefox, but without success
Please!
Thanks!
Did you also set the value
pref('general.config.obscure_value', 0);
See:
http://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/
Oooh, I forgot, sorry!!!
But I've added this line to /usr/lib/firefox/defaults/pref/hello.js and there's no change. Mmmmmggghh.
I've tried to update default version of Firefox in Ubuntu 12.04 to new Firefox 15, and I've moved my js file (hello.js) and my authconfig file (firefox.cfg) to new configuration folder /usr/lib/firefox/defaults/preferences. If I go to about:config in browser, I see that values in hello.js are correctly read, but the homepage configured in firefox.cfg still doesn't apear.
I've noticed also that default installation of Firefox in Ubuntu comes with a file called syspref.js located at /usr/lib/firefox/defaults/preferences with a commented line like defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://mike.kaply.com");
but I have discomment this I doesn't work either.
I've no idea what to do now.
Thanks for your so fast reply!!!
Sorry, the commented line in syspref.js file that comes in Ubuntu is
pref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://mike.kaply.com");
not defaultPref
Well, two things:
-If a put any configuration directive in my autoconfig file (firefox.cfg), it doesn't work. It seems its a problem about locating this file, but I've put it in /usr/lib/firefox and in /usr/lib/firefox/defaults/preferences, ...I don't know other possible places...I'll investigate this.
-If a put any configuration directive in my js file (hello.js), it works perfectly. But if I try to put in this file the homepage configuration (with "pref" directive instead of "defaultPref" and with the correct format "data:text/plain...") it doesn't work. In fact, it's what happens with the file "syspref.js" which is shipped by default with Ubuntu
Apparently defaultPref is broke in current Firefox builds and we are just now discovering it.
lockPref should work though.
you can test if your config file is working at all by putting errors in it and seeing if you get a popup.
Thanks.
I don't know why, but neither /usr/lib/firefox/firefox.cfg nor /usr/lib/firefox/defaults/preferences/firefox.cfg are found. I wish "general.config.file" could admit paths...
Other thing: lockPref works perfectly inside a my js file (hello.js). However, not only defaultPref doesn't work (as you say), but pref doesn't work neither.
Thanks a lot
I point out...lockPref works well with syntax:
lockPref("browser.startup.homepage","http://mike.kaply.com");
Syntax with "data:text/plain..." stuff isn't recognized.
I suppose you knew perfectly, but just in case...
Thanks
I have been using browserconfig.properties file to set browser.startup.homepage and browser.startup.homepage_reset but that does not seem to be working any more (Firefox 10.0.9ESR). Should I move to the method described above? Is browerconfig.properties not supported anymore?
browserconfig.properties:
browser.startup.homepage=http://mike.kaply.com
browser.startup.homepage_reset=http://mike.kaply.com
browserconfig.properties only has one line in it now:
browser.startup.homepage=about:home
So it's only used for the homepage (not reset).
browser.startup.homepage_reset is not used at all anymore.
Dear Mike,
I have been looking for many hours on how to set the homepage as a _default_ that a user can change and not have it forced as an effective policy. Many blog entries and forum participants I've tripped over on my search have been flummoxed by this, but you've explained it simply and with authority.
So: Thank you!
Kind regards,
Darren Collins
IT Services
University of Oxford
For the record, I had to set also
defaultPref("browser.startup.page",1);
in my autoconfig.js file for this to work, if I not set it, I can use pref or lockPref, but not defaultPref for browser.startup.homepage