(redirected from Programming.FireFoxExtensionDevelopment)



Developing Fire Fox Extensions

This is mostly a link-dump of things that I have found; some are used regularly, some are kept for future evaluation. I need to clean this up, and explain more of what I do. OtherMichael September 17, 2009, at 09:58 AM



Firefox addons developer guide
Getting started with extension development
Setting up extension development environment


https://addons.mozilla.org/en-US/developers/tools/builder - this is new. hunh. looks like it has some “pre-built” features for preferences, toolbars, etc.


Firefox/Thunderbird Extension Wizard
How to fix broken Firefox extensions
Updating extensions for Firefox 3
Firefox 2.0 extension development... aaand, we’re at 3.0, now. How accurate is this, still? BUT it’s by LifeHacker’s Gina Trapani
Trapani’s extension posts
FF Extension Dev quick-start


Mozilla FF Add-ons Policy
getting addon reviewed
Mozilla addons blog
Install Manifests
Problematic Extensions and workarounds
Mozilla Extension Developer’s forum - search for a lot of answers!


a framework?



http://irc.mozilla.org/ - list of chat channels





video tutorial bootcamp
extension tutorial
http://www.leogas.net/lugext/index.html - 2007 (?) suite of pages from a UCLS Comp Sci doctoral candidate
another tutorial - from 2004, so ditto


http://www.borngeek.com/firefox/toolbar-tutorial/ - for 1.5
http://www.leogas.net/lugext/index.html - for 1.5 again
http://www.gmacker.com/web/content/tutorial/firefox/firefoxtutorial.htm - for 1.5
http://www.businesslogs.com/technology/firefox_extension_tutorial.php - from 2005





XPI - Cross Platform Install

The installer is an .xpi file -- just make a .zip and change the extension.



Max version

http://www.mozilla.org/developer/ - should list the most recent version for download; s/b listed _somewhere_, though....
see also Extension Versioning, Update and Compatibility for info on updated the version numbers, but nothing concrete (that I could see)





hosting and updating

Stack Overflow: Packaging and self-hosting FF extensions
Stack Overflow: how does FF know when an extension update is available?
Stack Overflow: signing an XPI







MozUnit is a test-driven development framework for the Mozilla platform.
UxU - UnitTest.XUL




for study

Better GMail2 - compilation of multiple GM-scripts (for analysis)




First Run

Responsible first-run usage - don’t go crazy on modal dialogs, and put important into the first-run page.


Bugzilla: Add standardized support for first-run pages to install.rdf


mozdev: Running code on extensions first run, or update (was not loading the required code as of 2010-04-26)


Note that the page has some practices that are frowned upon in actual development because they will conflict in the global namespace with any other extension that uses that code verbatim


My own extended version of code on that page is below, with changes required to avoid conflicts:


// https://developer.mozilla.org/en/Code_snippets/On_page_load#Running_code_on_an_extension%27s_first_run_or_after_an_extension%27s_update
var myExtensionOverlay = {
    init: function(){

        var prev = -1, firstrun = true;
        var skipdate = ""; var dateNotSet = true;
        var showFirsts = true, debugVerbose = false;

        // no need for this var to be in the global name-space
        // NOR to share a potentiall common name. so, ssPrefs
        var svc = Components.classes["@mozilla.org/preferences-service;1"]
        var ssPrefs = svc.getBranch("extensions.myextension.");

        //gets the version number.
        var gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
        var current = gExtensionManager.getItemForID("myExtension@myExtension").version;


            prev = ssPrefs.getCharPref("version");
            firstrun = ssPrefs.getBoolPref("firstrun");
            dateNotSet = (skipdate == "");
            showFirsts = ssPrefs.getBoolPref("showfirstruns"); // allows start pages to be turned off for partners
            debugVerbose = ssPrefs.getBoolPref("debugVerbose");


            alert("myExtension error in auxilliary.js: " + e.message
                  + "\n\ncurrent: " + current
                  + "\nprev: " + prev
                  + "\nfirstrun: " + firstrun
                  + "\nshowFirstRuns: " + showFirsts
                  + "\ndebugVerbose: " + debugVerbose);


            // debugVerbose s/b set to false for AMO and self-builds
            // leave as manually set for beta-builds
            if (debugVerbose) {
                alert("current: " + current
                      + "\nprev: " + prev
                      + "\nfirstrun: " + firstrun
                      + "\nshowFirstRuns: " + showFirsts
                      + "\ndebugVerbose: " + debugVerbose);

            if (dateNotSet) {
                ssPrefs.setCharPref("firstskipdate", Date());

            // change this depending on the branch
            var newPage = "http://www.myextension.com/install/whatsnew_self.html?ver=" + current;

            // NOTE: showfirst-check is INSIDE both code-blocks, because prefs need to be set no matter what.
            if (firstrun){

                if (showFirsts) {
                    // Insert code for first run here
                        gBrowser.selectedTab = gBrowser.addTab("http://www.myextension.com/welcome.html");
                        gBrowser.selectedTab = gBrowser.addTab(newPage);
                    }, 1500); //Firefox 2 fix - or else tab will get closed (leave it in....)


            if (prev!=current && !firstrun){ // !firstrun ensures that this section does not get loaded if its a first run.

                if (showFirsts) {
                    // version is different => upgrade (or conceivably downgrade)
                        gBrowser.selectedTab = gBrowser.addTab(newPage + '&prev=' + prev);
                    }, 1500); //Firefox 2 fix - or else tab will get closed
        } // end finally

        window.removeEventListener("load",function(){ myExtensionOverlay.init(); },true);


// fires on browser launch, which includes open-link-in-new-window
window.addEventListener("load",function(){ myExtensionOverlay.init(); },true);









XUL - XML User-Interface Language

see also Wikipedia:XUL
Joy of XUL
XUL Tutorial
Getting started with XULRunner
XUL tools
XUL Explorer






see also: XML




see also Wikipedia:Resource_Description_Framework



launch the “dev” profile

"%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev


specifically, that launches the pre-existing profile named “dev” - if it doesn’t exist, you’ll get the profile selection pane.


generally, I create shortcut called ff-pm that launches the profile-manager to allow me to select what I want, now.


see also FireFox#profiles



live development

Registering your extension in the Extension Manager


With Firefox closed, create a “pointer” file with the same name as your extension’s Description:ID (as found in your install.rdf) in //path/to/profile folder/extensions/ and edit it so that it contains the path to your extension’s folder (the root containing containing install.rdf and chrome.manifest files).


E.g. helloworld’s ID is helloworld@mozilla.doslash.org and we would like to register it in X:\Dev\helloworld\ (i.e. there is X:\Dev\helloworld\install.rdf file etc.). Just put a single line into the file at this path: profile folder/extensions/helloworld@mozilla.doslash.org


X:\Dev\helloworld\ - note trailing slash and no CR - single line, remember?


(Re)Start Firefox, and check that your extension is installed.



run code at install/upgrade

Stack Overflow How to run code during the “firstrun” of a Xulrunner Application - answers and vague, but I tracked this down elsewhere. need to document it in here.... (it did take me a few weeks of on-off searching to find the right terms to find the right info)



Extensions I’ve written

Skip Screen - a Grease Monkey script that is slowly growing out of its short pants



See Also

Fire Fox
Grease Monkey
FireFox#dev - for my list of developer extensions
Extension Build



Category tags

Programming browser development web firefox