An audience of two

All | CEC | FBinfo | General | Humour | iPhone | Java | Music | W(h)ine | X64

20061006 Friday October 06, 2006

Setting the default home page in Firefox

Configuring the default homepage in Firefox is trivial, provided you ignore the official instructions. Just manually edit the file /opt/sfw/lib/firefox/defaults/profile/prefs.js (assuming your copy of Firefox is installed in /opt/sfw) and add an entry that reads user_pref("browser.startup.homepage", "Your URL here"); Curious how I found that? Then read on.

As I commented earlier, configuring the default homepage for Firefox turned out to be trickier than I thought it needed to be. So last night I took another crack at it. Now here are two easy ways to configure Firefox. One is to manually edit your .mozilla/firefox/rAnDoMcharacters/prefs.js file; the other, preferred method is to enter the URL about:config and configure it from the user interface. Looking at about:config I see an entry called browser.startup.homepage having the value resource:/browserconfig.properties. So logically it seems that I want to override the value of either of these.

I checked the Mozilla Wiki and it confirmed that to change the default homepage the official method is:

  • Modify browserconfig.properties - browser.startup.homepage and browser.startup.homepage_reset or use the data:text stuff referenced above in firefox.js. browserconfig.properties lives as a text file where the EXE is.
The file /opt/sfw/lib/firefox/browserconfig.properties contains two entries: browser.startup.homepage=http://en-US.start.mozilla.com/firefox?client=firefox-a&rls=org.mozilla:en-US:official browser.startup.homepage_reset=http://en-US.start.mozilla.com/firefox?client=firefox-a&rls=org.mozilla:en-US:official

I began by trying to edit the file, but for some reason that didn't seem to do a damn thing. So then I went looking for where the browser.startup.homepage was set, and I found it in /opt/sfw/lib/firefox/defaults/pref/firefox.js. However once again, editing that didn't seem to work either.

Next I found /opt/sfw/lib/firefox/defaults/profile/prefs.js. This file contains the same header file as the local prefs.js and looked very promising, so I tried editing the comment and started Firefox, but when I looked at the local prefs.js it had the default comment again. Very frustrating.

When I reached this point at CEC I started Yak shaving and ended up hacking the file /opt/sfw/lib/firefox/chrome/en-US.jar. But clearly that's far from optimal; there had to be a better way. So I ran truss on firefox to see what it was actually doing at startup time and I discovered that it actually writes the local prefs.js twice. It begins by copying the defaults/profile/prefs.js above, then adds some additional properties and then rewrites the file. So I simply added an entry that read user_pref("browser.startup.homepage", "http://www.sun.com"); blew away the .mozilla directory, restarted Firefox and bingo! the homepage was set to Sun's web portal.

Now obviously this only sets the default; the user is free to overwrite that default using Edit/Preferences or about:config. If you wanted to lock that down it would be difficult; one way would be to create a wrapper script for Firefox that manually edited (or, if you wanted to be particularly antisocial, removed) the user's prefs.js; since Firefox is open source another option might be to compile your own version that always over-rode the default homepage setting. (You probably wouldn't need to rebuild the entire thing; just find the appropriate class and patch the jar file.) But since the user could bypass this by simply downloading a local copy of Firefox or another browser such as Opera, there seems very little point.

Permalink del.icio.us | furl | slashdot | technorati | digg Comments [0]
Tags:

Stinkin' Badges

Santa Cruz Mountains wine info on Wikispaces


follow davetong at http://twitter.com

Add to Technorati Favorites

www.flickr.com
This is a Flickr badge showing public photos from davetong. Make your own badge here.

Locations of visitors to this page

Calendar

« October 2006 »
MonTueWedThuFriSatSun
      
7
9
11
12
13
14
15
16
18
19
20
21
22
23
24
25
26
28
29
30
31
     
Today

RSS Feeds

XML
All
/CEC
/FBinfo
/General
/Humour
/iPhone
/Java
/Music
/W(h)ine
/X64

Search

Links


Navigation



Referers

Today's Page Hits: 9