Monday, April 28, 2008

HOWTO write a firefox plugin

I'm in the process of writing my first firefox plugin and have recorded my experiences here. The HOWTOs and links I used were:


The most important firefox extensions are:

  • Console2
  • Extension developer's extension. The 'reload all chrome' is useful for stuff that is otherwise cached.

To create the xpi file for publishing you need to change your chrome.manifest to point to the jar file (I keep another chrome.manifest for packaging in the repository so I can just copy it over). The ordinary manifest looks like this:

content myextensionname chrome/content/
skin myextensionname classic chrome/skin/
overlay chrome://browser/content/browser.xul chrome://myextensionname/content/browser_overlay.xul
locale myextensionname en chrome/locale/en/myextensionname/
and the packaging one looks like this:

content myextensionname jar:chrome/myextensionname.jar!/content/
skin myextensionname classic jar:chrome/myextensionname.jar!/skin/
overlay chrome://browser/content/browser.xul chrome://myextensionname/content/browser_overlay.xul
locale myextensionname en jar:chrome/myextensionname.jar!/locale/en/myextensionname/

I use these commands to create the jar and xpi:

cd chrome
zip -r myext.jar * -x \*.svn\*
cd ..
zip myext.xpi install.rdf chrome.manifest chrome/myext.jar

No comments: