O'Reilly logo

Firefox Hacks by Nigel McFarlane

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #83. Add a New Command-Line Option

Customize the startup process and the process of starting windows by adding support for new command-line arguments.

The set of Firefox command-line arguments isn't fixed. You can add more options if you want. In the complex case, new command-line options can be compiled up into dynamic link libraries using C/C++. It's easier to use a simple JavaScript script, though. This hack shows how to implement the simple case. We'll make a --my or /my option that displays a page stored in the install area on startup.

Preparation

The straightforward thing to do is to add an option that starts up a window of your own design. In order to do that quickly, you have to sidestep the Extensions system by hacking on the install area directly. You have to create a specific set of objects to make everything hang together properly.

As in [Hack #82] , start by shutting down all Mozilla programs in preparation for new component registration. Find the file named compatibility.ini in your Firefox profile. Edit it and decrement the Build ID date by one day. Save the file. The compreg.dat component registry is in the same directory if you want to inspect it while you're there.

Warning

Make a backup copy of the compreg.dat file before proceeding.

Next, move from the profile directory to the Firefox install directory. In there, you'll find a components directory. Go to that directory. You'll see there's a number of DLL (or .so) dynamic link libraries, with their accompanying ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required