Recently I completed my first extension for Mozilla. It was a good experience. Though not particularly well documented, the extensibility of Mozilla is excellent. I thought I’d share a few tips on the process. I had to dig for most of this, so some of my conclusions may not be completely accurate and I might not use the appropriate terminology in each case.
Mozilla extensions are typically distributed in a single file for easier installation. These files end with the extension XPI and are often called ‘zippies’. If you host your website and would like folks to be able to click the link and start the installation, you’ll need to make sure that you are serving zippies as application/x-xpinstall. You should ask your ISP for help doing this if you need it.
The XPI is simply a zip file. At this writing, the zip file will generally contain a JAR file and an install.js file. The JAR file is simply another zip file with the extension of JAR and the install.js is simple JavaScript that tells the install process exactly what to do with the extension you’ve packaged. The easiest way to figure this out is to look at some existing extensions and see how everything works. Except for customizing a couple of variables specific to your app, finding an existing install.js and using it may be your best bet.
Much of the magic to Mozilla extensions happens in the contents.rdf files, which are also known as manifests. If you are familiar with RDF, as used in syndication, this should help you understand what is contained in these manifests, though such knowledge probably isn’t required to create an extension. The manifest is essentially a list of what is contained in the file and how to integrate it with the application chrome, or user interface.
The interface of your extension, often called an overlay, is written in XUL (rhymes with cool). XUL is really nothing more than markup language, and if you are familiar with HTML you should be able to pick up the nuances of XUL easily enough. There are a number of references online to XUL, though many of them are not terribly in-depth. Sometimes you need to guess a bit about the details of implementing each element. Using other extensions for insight may prove helpful.
In Mozilla, the browser component is itself written in XUL, and I found a number of the answers I was searching for in the browser component. Other than other extensions and the actual Mozilla browser component, I found that Google was often my friend (as always).
While XUL handles your presentation information, the actual work is handled by JavaScript. I’m not particularly adept at JavaScript, but found that I was again able to look at the work of others and look up questions on Google in order to find most answers.
In summary, it seems to me that if you can build web pages that include HTML and JavaScript (including the use of CSS), and are able to use a zip tool to pack up directories, you should be able to create your own Mozilla extension. Now get to work!
Comments
2 responses to “Mozilla Extensions”
You can’t install it at a command line, or anywhere else. As an extension, it requires the Mozilla functionality in order to work.
Hey man, I wanna know how to install this extensions outside the mozilla environment, as at command line! Would you help me? Please, answer me by email…
Andre Pedralho