How to create Firefox extensions
Did you ever have a great idea for a Firefox extension but didn't know where to start? It is actually not that difficult to create add-ons for the Firefox browser. To begin, you need knowledge of JavaScript as it is the language that is used to create the extensions. While that may look like a daunting task at first if you never came into contact with JavaScript before, it is actually one of the easier programming and scripting languages to learn.
To create extensions, you have two options that can be best described as an easy or simple way, and a hard way. As you may imagine, both methods have their advantages and disadvantages.
If you prefer the simple option, you can go ahead and create a userscript that can be loaded if add-ons such as Greasemonkey are installed or if the browser supports scripts natively. The advantage of Greasemonkey is that you do not have to deal with installing extensions in the browser so that you can concentrate fully on the script ahead.
It may also mean that you can offer the script for other browsers provided they support the functionality.
Greasemonkey enables you to install JavaScript files in the browser that can manipulate or improve a single website, a group of sites or all sites that are visited in the browse. To get started, check out the beginner's guide to Greasemonkey scripting or browse the collection of scripts on the userscript website to learn from their source code.
The hard option is to create a full extension for the Firefox browser. This not only involves creating the functionality of the extension using JavaScript, but also packaging the extension correctly as Firefox expects certain files to be included.
Downsides are that you have to repack and restart every time you modified your script (Update: no longer necessary if you are using the new add-on api).
Upsides are that you can do a lot more then you can with userscripts and you can distribute your extension a bit easier.
Also check out the links at the bottom of the tutorial if you get stuck, the forum he links to for example can be a big help.
Update: The tutorial website is no longer available. You can alternative check out the how to develop a Firefox extension at the Mozilla blog to get some pointers to get started developing extensions for the Firefox web browser. The detailed tutorial offers preparation suggestions and code examples, basically everything to get started right away.
I suggest you check out the Mozilla Add-ons blog and the Mozilla Developer Network website for additional information and tutorials.
Here are a couple of additional resources that you may find useful in this regard:
- How to develop a Firefox extension post on the Mozilla Add-ons blog.
- Start Making Firefox Add-ons on Mozilla Developers.
- Extension Development forum on mozillaZine.
You can use http://www.arantius.com/misc/greasemonkey/script-compiler.php to compile a GreaseMonkey script into a full-featured independent Firefox extension!