Making a Mozilla installation modifiable

Mozilla's user interface is made up of XUL (described below), XBL (a topic for another tutorial), JavaScript, CSS, and image files. XUL, XBL, JavaScript, and CSS files are all in text format and can be edited in a standard text editor, while image files are in binary GIF, JPG, or PNG format and must be edited with an image editing program.

The files are then collected into a series of JAR archives, which are just ZIP files that contain a specially formatted "manifest" file which describes the contents of the archive so Mozilla knows what to do with them.

Although JAR archives are binary files, Mozilla's UI is not compiled into machine code; Mozilla instead builds its UI from the non-compiled files in the archive each time it starts up. Because of this, we can modify the files in the archive and see our changes to the UI merely by restarting the application. This makes modifying Mozilla's UI much easier than for many other applications.

Although Mozilla stores the UI files in JAR archives, it can also access them in their original, unarchived form, which is useful for the extensions developer because it makes it unnecessary to extract the files from the archive before changing the code and then re-add them to the archive afterwards. Instead, you only have to extract them once and can then make as many modifications as you like.

To make Mozilla modifiable, we will first extract the UI files from the archives using an unzip utility, then edit Mozilla's registry of UI files to use the extracted files instead of the original JAR archives.

The archives are stored within the chrome subdirectory of the Mozilla installation directory. Use your unzip utility to extract all files in that directory with a .jar extension. Make sure you extract them into the same (chrome) directory in which they are located. On Unix-like operating systems with bash-like shells, you can run the following command within that directory to accomplish this task:

for file in *.jar; do unzip $file; done

On operating systems with DOS-like shells, the following command accomplishes this task:

for %file in (*.jar); do unzip %file 

Note that there are platform-specific files — en-mac.jar, en-unix.jar, and en-win.jar — in that directory. Extract only the one appropriate for your platform.

After extracting the files we will modify the Mozilla chrome registry to use the extracted files instead of the original JAR archives. The chrome registry is a file that lists each major Mozilla component and where in the chrome directory its UI files are located. It is located in the chrome directory itself and is called either chrome.rdf or installed-chrome.txt (or both).

The registry contains a bunch of complicated configuration statements in which you will find a number of URLs of the form jar:resource:/chrome/SOMETHING.jar!/SOMETHING-ELSE... which point to directories within the JAR archives. Change them so they point to the extracted files by removing the leading jar: and the part in the middle that says SOMETHING.jar!. If you have Perl on your system, you can do this with the following command:

perl -pi.orig -e 's/(jar:)|(\/[^.\/]+\.jar!)//g' chrome.rdf installed-chrome.txt

For example, to convert the URL jar:resource:/chrome/comm.jar!/content/necko/, change it to resource:/chrome/content/necko/.

After you make these changes, try starting the copy of Mozilla you have modified. Make sure you start the modified copy and not the default installation on your machine, and shut down "quick launch" if you are on Windows and that feature is enabled. If Mozilla starts up and displays a normal-looking web browser window, then you have successfully made your copy of Mozilla modifiable! [mention that if you have Perl, you can also do this with Patch Maker]

Document Tags and Contributors

Contributors to this page: Kohei, Yoshino, Sheppy, trevorh
Last updated by: Sheppy,
Hide Sidebar