Over the past 6 months, I’ve begun writing two different Mozilla-based extensions. One for Thunderbird, one for Mozilla Suite/Fire{bird|fox}. In my experience, Mozilla is an amazingly powerful and flexible platform: it provides a cross-platform foundation to build applications on, but more importantly it’s an application that has the right attitude. The attitude of “we’re building the best app we can, but lots of smart people don’t work for us, so we’ll give them the tools they need to make the app (and their lives) better.” That’s cool; that’s the right attitude to have. Of course, extending Mozilla through an extension is easier said than done in many ways. I have yet to find a site listing the “one, best way” to put together an extension. There’s lots of ways to do it, and as a result, lots of confusion when the two examples you’re drawing from use two different approaches.
With that and the coming Firefox 1.0 extension format change, I decided to put together something I’m calling DemoExt. The goal of DemoExt is to provide the simplest amount of functionality necessary to demonstrate how to make a localized, cross-platform extension that works with Firefox and Mozilla Suite. It currently does the following:
- overlays the browser window, adding an item to the status bar (this seemed like the simplest example of modifying the browser UI)
- provides a simple preferences/options dialog, both in Firefox and Mozilla Suite
- uses localization files to store strings (this was always way too hard for me to figure out, so this was as much a learning exercise for me as anything else)
That’s it! In addition to these “features”, the DemoExt package has a few tricks up it’s sleeve as well:
- a
build.shscript which generates an XPI in the new 1.0 format - an
install.jsscript which installs the DemoExt into the users’ profile, mimicking the 1.0 Firefox approach - an
extension.rdfwhich provides the Firefox 1.0 format metadata
newext.py, a Python script which generates a new source tree from the demo tree, with the appropriate files/directories renamed; hopefully this will allow people to get started writing extension faster, without worrying about how to install them or how to lay out their directory structureThere are still a couple of things I’m working on. First, I need to make the preferences code load the defaults from the demoext_prefs.js file. I want to make newext.py a little smarter about how it generates the new tree. Finally, I’d like to create a similar package for Thunderbird, since the current code is very browser-oriented.
You can download DemoExt here, or browse the CVS tree . As always suggestions, feedback and corrections are welcome. Enjoy!

22 Comments
You’ve linked to an older version of the format change. The current one is http://weblogs.mozillazine.org/ben/archives/005500.html
Hi
I saw your page describing bits of how to create extension modules for firefox. However, I have not found any documentation of what API’s to use and like some official documentation on how to write extensions. Do you know where to find such information?
After a really exhaustive, exhausting search, I am astonished by the lack of docs on writing Firefox extensions. It’s a little Twilight Zone-ish how there’s all these extensions, all kinds of forums, support sites, and not a single bit of official documentation on how to write one! The only thing I found with any real substance was this, but it still freaks me out how hard I had to dig for it. Why isn’t there something big and obvious at mozdev.org and/or mozillazine.org??? Like George said above, even this page entitled Writing Mozilla Extensions doesn’t tell you how to write Mozilla extensions!!! WTF???
Hi Seeing that you write extensions for mozilla I hace a suggestion
Put ALL GROUPED TOOLBAR COMMANDS on the context menu/ So nice
A right click and I can access all my toolbars drom the context menu
No need for side bars and header bars and task bars!!!!!!!!!!!
For now, putting HOMEPAGE AND EXIT on the right click menu would be A boon to all of us!!!!!!!!
Keep in touch
Loy Sequeira
I suppose Lee is technically right, I don’t tell you to write Mozilla extensions explicitly. However, you’ll see that the DemoExt code does contain the framework necessary for writing your own. I have no patience for the “just dump it in my lap” attitude. If you can’t be bothered to read the code and read the wealth of resources that I point to here and at the mozCC pages, I guess you don’t really want to extend Mozilla that badly.
Loy, really, grammer and punctionation are ”/So nice”.
Sorry folks, I don’t have time to do it all, and if a project doesn’t interest me, I’m probably not going to spend my time working on it.
Nathan
Pretty cool. I was thinking about doing something like this a while ago, even for my own use, since I reuse my extension frameworks all the time. I currently have an install.rdf generator here, but I think a full-blown extension skeleton generator would be sweet. Making it a CGI would be useful too, I think. If you’re interested in collaborating on turning your framework into a CGI, drop me a line.
Any news on the Thunderbird framework? I want to add some functionality to the process of adding attachments to an email…but this is all pretty new to me, and a bit daunting.
Don’t forget XUL Planet
Like most of the ‘open-source’ community, your comment, ‘If you can’t be bothered to read the code and read the wealth of resources that I point to here and at the mozCC pages, I guess you don’t really want to extend Mozilla that badly.’ demonstrates a fundamental flaw in the open-source(I know FireFox et al, are not true open-source, but they are close) community.
Whenever help is needed, and answers supplied, the answers almost always assume a level of knowledge that, if the ‘asker’ had, they probably would not need the question answered. Your post, and the ‘wealth of resources’ seem to be written for prople who have already written FireFox extensions(or have extensive knowledge of the process).
I would love to be able to extend FireFox, but there seems to be no place for me to take ‘baby steps’ to get up to speed.
Not only do I agree about the dearth of resources about Developing in Firefox I will go one farther. I spent the better part of a day figuring out what you develop for firefox in!!! What an extension/application would look like etc.
I am not saying lay it out the way that you would for someone that can’t program. But even an explanation aimed at the regular C++ program would be welcome.
Boyzoid is right. I am also trying to figure out how to write xtensions, but the lack of official docs is a hurdle.
The OSS community assumes a certain amount of sophistication in the user; sort of like an elite club mentality. Remember when we were kids and you weren’t allowed in the “club” unless you knew the magic word? It is sort-of like that.
On the other hand, the Microsofts of this world will continue to put out copious documentation and hand-hold newcomers, enough to get them to come over to their side. Of course MS won’t give away all the goods; they’ll just give out enough to attract the non-elite crowd. Once they’re in, they’re screwed (obviously).
If the OSS community were to adopt a more open mentality, they could take the oxygen out of MS’s lungs. But there’s no chance of that ever happening, as long as these guys continue to think they’re “3l33t”...
I was disapointed too! I thought this is a tutorial of telling you how to write a simple extension. After reading all, there wasn’t anything at all! Seriously, up till now, I still havenn’t found any simple tutorial of teaching you how to write a firefox extension. I have been wanting to try a few years ago, but the lack of docs just stopping me from doing it. I think the title of this page should have been changed to something else, “Some scripts to help you write extension”.
I’ve been spending a fair amount of time working to learn to write mozilla extensions as well. A lot of experimentation and a lot of
hard work. But it’s fun … because I’m that sort of weirdo.
I have known musicians who loved their work so much that they would play all night for free. I have never known a plumber who would do the same. Therefore it is much easier to find good free music than it is to find good free plumbing. And so it is with coders and technical writers. Don’t get me wrong, I have known some very good technical writers. But I have never known one who spent their vacations doing it.
And there are some mixed feelings about making things too easy. When I was a kid, there was no such thing as public internet access. The
only way that I could get on the net was to break into the machines at the University of Michigan. But god, was it worth the effort. Reading usenet was a joy. It was like reading one docteral dissertation after another. But then it got easy, and what do we have to show for it? I stopped bothering to try reading usenet years ago. Perhaps if I had a smaller penis, I could better appreciate what the throngs attracted by easy access have contributed. But I just miss the days when you could poke your head in and read something worth the trouble.
One more comment before I sign off. I suspect that if you started posting things in the forums like ‘I’m trying to gather information for a document on how to write a firefox extension, you could get more help than you could handle.’ So if you don’t like it, fix it. Just don’t make it too easy, OK?
First off, I have now realized that a majority of the people reading this have not yet written anything. Those who have read everything above and are interested in learning something about the Extensions are left with nowhere to go. So, here I am. I stumbled upon this site through some leap of synchronicity while looking to answer the question: “What language(s) are being used to write the code for a browser.” A little background if I may: I am at an indeterminant age, having recently (in the last two months) learned html, javascript and perl (I see them as one language). I am an Aries and it is hard for me to not sound cocky. I want to sound like I know what I’m talking about, because I do (See what I mean.). I am an artist and a mathematician, a physicist, a philosopher, and just about anything I set my mind to. Currently its web design. However, I have just read the writings of a whole lot of people with a specific ambition: Learning how to improve Mozilla. I like Mozilla. I also have some really good ideas on how to make a new browser. Something visually, aurally, intuitively, scientifically and spiritually awesome. I don’t use the word awesome very often, but it seems to fit here. I can picture it, I can hear it, I can feel it, I can understand it all at the same time. Look/Sound/Feel like your kind of browser? I think I might just start a non-profit corporation to get’er done. Want in? It means sharing information, not hoarding it. I have just come to realize the importance of and philosophy behind an ecumenical community. It is to better the human interest, it is to better humanity. Understand? Drop me an e-mail, and we’ll get under way. scott_barta@hotmail.com All it takes is a notepad.
Dear Scott,
You should be writing “Get rich quick” spam.
I’m on my way to writing an extension too and this is the first hit I got on google for documention on writing one.
Ulike others I disagree about the need for “formal” documentation. The Open Source hacker community is by nature into tearing things appart and rebuilding them. The reason there are so many extensions despite the lack of docs is because people simply pick an extension they like and modify it to suite their need.
This is common practice in the Open Source comunity where there aren’t enough resource to write up formal documentation. I suggest that every one here search for good docs take their favourite extension and tinker with it. You’ll be amazed the amount you can get done just in the process of playing with other people’s code.
hey guys, also found this first on google, was a bit disappointed after a while but then got looking around more and found this helpful guide on the mozilla website http://www.mozilla.org/docs/tutorials/tinderstatus/ a very useful how to write an extension tutorial. just thought I’d let you know as I guess google will send more people this way. have fun coding, I am.
I wrote a small Firefox extension for the library where I work and I’ve collected many useful links on my page:
http://everything.no-ip.org/mb/
Bye,
Luca
Even Felix’s link does not include a guide an API-driven guide on how to write an extension for Firefox, but rather how to write the install routine for an extension.
As others have mentioned, this is the crude reality of OSS software – poor, often non-existent documentation. Many times I have had to consult other pieces of code, dig into headers, look at embedded README files and docs hidden in source trees to even get an inkling of how to do something.
I remember when I worked on getting an LDAP-driven virtual mail server going using Courier IMAP/POP and Postfix. It took me literally months to piece together hundreds of disparate chunks of “Howtos” people had written (at least THOSE were out there) to get it working. It was, needless to say, hard-fought and -won knowledge. Many times consulting forums and mailing lists were the only way to piece together the final bits of information to get over the hump where I got beyond conceptual into functional.
I have been an avid OSS user since ‘92 a Linux junkie for well over a decade but I am continually amazed at the lack of documentation available. I admin systems and networks professionally, but many times you have to hope there is a good O’Reilly or WROX book out there that details how to install, configure, and maintain XYZ piece of software. Otherwise you waste days, weeks, months groping around for the material you need.
I suppose that is all part of the “hidden cost” of using OSS and the attitude of moral superiority by OSS coders who couldn’t be bothered to make their stuff accessible to a large chunk of the OSS-using population only exascerbates the problems.
Okay. I’m a total beginner as a programmer. I know html and the tiniest bit of Javascript and cgi scripting. I’m probably in the same group as most people who posted skills-wise. I Googled to get here. I also followed all the links.
Here is the absolute essential starting point if you want to start learning anything instead of crying about how hard it is:
http://roachfiend.com/archives/2004/12/08/how-to-create-firefox-extensions/
Also absolutely essential: http://www.xulplanet.com/
Worth a look for sure: http://nexgenmedia.net/docs/extensions/
None of this requires any experience as a full-fledged app developer. You don’t have to be a C programmer. You DO have to be able to look at the source code for a project knowing what it does and start figuring out how it works by examining and playing around with the code.
If that’s too scary for you, you should just forget it and suggest your ideas to other people more capable to do something with them. If you never ask yourself your questions before you ask them to someone else, I’m talking to you especially.
Otherwise have fun.
I saw “Performansing For Firefox Extension” its really has a interesting features. I like to make little bit same thing for my personal purpose.
I like to gives user a chance to suggest there website in my personal web directory, or if its already there then review and comment for that site. User can gives vote / rank for that site with the selected category.
How to implement this feature for my personal use using FFE ,as i am very new for this type of extension. I need that xpi who makes my work simpler.
Please help me out.
Thanks!!
Jeez,
Just download some small extension and have a go at modifying it. See what works and what does not. This is NOT rocket science, people. In the time it took you guys to respond to this blog, you could have been well on you way already..
2 Trackbacks
Creating Firefox / Mozilla Extensions
http://extensions.roachfiend.com/howto.php http://extensionroom.mozdev.org/ http://devedge.netscape.com/viewsource/2002/toolbar/ GUID Generator: http://extensions.roachfiend.com/cgi-bin/guid.pl Firefox Extension RDF Generator: http://ted.mielczarek.org…;
[...] http://yergler.net/blog/2004/05/20/writing-mozilla-extensions/ – another blog. Nothing there at all. [...]