Additional information: How to build a Firefox extension


Mozilla pins (wallpaper) on Flickr – Photo Sharing!

This entry inspired me.
How to build a Firefox extension (lifehacker.com)

I use Mac OSX 10.5 and Firefox 3.0.5.

Set up your development environment

ref:
https://developer.mozilla.org/en/Setting_up_extension_development_environment

Small script for starting firefox.
% cat ~/bin/firefox-debug.sh
#!/bin/sh
/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev

I created a new profile “dev” for development.

I mainly use 2 add-ons.

Event Spy catch the events like “click”, “mousedown” etc.

Debugging

ref:
https://developer.mozilla.org/en/Extension_Frequently_Asked_Questions

Use dump(); for simple print debug.

Browser layout overview

If you want to hook and change default event, you should learn about browser layout. browser.js, browser.xul may help you. These files are in /Applications/Firefox.app/Contents/MacOS/chrome/browser.jar
% unzip browser.jar
Or you can find in the firefox source:
% tar jxvf firefox-3.0.5-source.tar.bz2
% find . -name browser.js
./browser/base/content/browser.js

Firefox toolbar and some default buttons are made by browser.xul. Some events and functions defined at browser.js.

XUL tips

<menupopupset> needs <popupset>. Use document.loadOverlay for <popupset>. It doesn’t work with document.createElement().

Release candidate

% zip -r ~/your-add-on.xpi . -x "*.svn*"

If you submit your add-on then its status turns in sandbox. A few days later your add-on will appear Newest Add-ons. (you must log in and check “show experimental add-ons”)

This entry was posted in Tweak and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.