Change title of Firefox window after website has been loaded.

Sometimes, it may be useful that the title of opened Firefox window changes when a webpage is completely loaded. It may not be much helpful for web developers as they are already digging deep into JavaScript code of Firefox browser. But it can be helpful in situations where you don’t want to keep on checking manually if page has been loaded. Therefore you can kind of automate process of knowing when a webpage is completely loaded by changing the title of Firefox window and letting some other process keep an eye on opened Firefox window’ title and notify you when it has been changed (think about xwininfo command in X working environment). You can also do it for fun and I tell you, it is really easy. I won’t go into details of coding and implementation logic behind it. Just follow the steps listed below and you should be able to do it.

Assumptions: Firefox Version 20.0 (Linux, OpenSUSE 11.4)
Firefox Version 30.0 (Windows XP)

On Linux:

  • The Firefox installation folder shall contain file omni.ja (at my system i can find it in /usr/local/firefox).
  • Copy it some location e.g. /tmp folder.
  • Run command: cd /tmp
  • Verify that file omni.ja is present in /tmp folder.
  • Run command: unzip omni.ja -d omni
  • A folder omni will be created in /tmp folder.
  • Open the file /tmp/omni/chrome/browser/content/browser/browser.js
  • Search for function:                                                                                                                                             onStateChange: function (aWebProgress, aRequest, aStateFlags, aStatus)
  • In this function, search for line:                                                                                                               else if (aStateFlags & nsIWebProgressListener.STATE_STOP)
  • Before closing brace of this “else if” structure, add following line:                                            document.title = “Your desired title”;
  • Save the changes to file.
  • Go to folder /tmp/omni
  • Run command: zip -qr9XD omni.ja *
  • Take this omni.ja file and replace original omni.ja file in Firefox installation directory with this file.
  • That’s it.
  • Sometimes, it is necessary to clear Firefox JavaScript cache before changes in omni.ja file take effect. Therefore you can either start Firefox as:                                               /usr/local/firefox/firefox –purgecahces http://www.google.com                                                        OR                                                                                                                                                                               You can set environment variable MOZ_PURGE_CACHES as 1 so that JavaScript cache is cleared:                                                                                                                                                        export MOZ_PURGE_CACHES=1
  • After your changes are in affect, you can set MOZ_PURGE_CACHES back to 0, if you want to utilize JavaScript cache.                                                                                                                    export MOZ_PURGE_CACHES=1

On Windows XP/7:

  • You will find two omni.ja files in Firefox installation folder. For example, i have Mozilla Firefox installation in folder: C:\Programme\Mozilla Firefox (It could be different folder on your system. Figure it out).
  • I can see one omni.ja file in that folder and one in C:\Programme\Mozilla Firefox\browser.
  • Take the one in folder C:\Programme\Mozilla Firefox\browser.
  • Create a new directory somewhere on system (Let’s say on Desktop)
  • Copy omni.ja to newly created folder
  • Rename it to omni.zip and extract it using winzip.
  • Locate file chrome/browser/content/browser/browser.js
  • Repeat steps f) g) h) i) which i mentioned for Linux.
  • Compress all the extracted folders together by selecting all files and directories in newly created folder on Desktop (delete original omni.ja file).
  • Right click -> Send To -> Compressed Zip folder.
  • Rename newly created zip file to omni.ja
  • Copy it back to C:\Programme\Mozilla Firefox\browser
  • That’s it.

If you are facing any difficulty in following these steps, don’t hesitate to ask questions in comments 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s