Friday, April 4, 2008

Create Firefox Multiple-Item Packages - maddon.py

I have a (growing) list of Firefox add-ons that I use all the time, so whenever I am customizing a clean machine, it's a tedious process browsing to each add-on's page and going through the installation procedure repeatedly.

I learned that the Mozilla framework supports Multiple-Item Packages -- multiple add-ons and/or themes grouped together in a single file. I've written a Python script which takes a list of add-ons and themes in any format I could think of and generates a multiple-item package for you -- maddon.py, for "multiple add-on." You can pass to it:

  • local .xpi/jar files
  • directories of .xpi/jar files
  • text files, with each line containing a .xpi/jar file
  • remote URLs
  • websites which will get scraped for .xpi/jar files

I use the text file VicsAddons.txt to generate my personal add-on favorites:
# Download Statusbar
https://addons.mozilla.org/en-US/firefox/addon/26
# Google Browser Sync
http://tools.google.com/firefox/browsersync/install.html
# CustomizeGoogle
https://addons.mozilla.org/en-US/firefox/addon/743
# Better Gmail 2
http://lifehacker.com/software/exclusive-lifehacker-download/better-gmail-2-firefox-extension-for-new-gmail-320618.php
# Better GCal
http://lifehacker.com/software/exclusive-lifehacker-download/enhance-google-calendar-with-the-better-gcal-firefox-extension-260074.php
# Better GReader
http://lifehacker.com/software/exclusive-lifehacker-download/trick-out-google-reader-with-better-greader-262020.php
# Adblock
https://addons.mozilla.org/en-US/firefox/addon/10
# dragdropupload
https://addons.mozilla.org/en-US/firefox/addon/2190
# Firebug
http://getfirebug.com/
# Google Gears
http://dl.google.com/gears/current/gears-osx-opt.xpi
# PicLens
http://www.piclens.com/site/firefox/tutorial_pl_ff.php

Running it produces the following output:
$ maddon.py VicsAddons.txt
Parsing 'VicsAddons.txt'
Parsing 'https://addons.mozilla.org/en-US/firefox/addon/26'
Scanning page...
Downloading 'https://addons.mozilla.org/en-US/firefox/downloads/file/24860/download_statusbar-0.9.6.1-fx.xpi'
Adding 'download_statusbar-0.9.6.1-fx.xpi'
Parsing 'http://tools.google.com/firefox/browsersync/install.html'
Scanning page...
Downloading 'http://dl.google.com/firefox/google-browsersync.xpi'
...

Created 'VicsAddons.xpi' with the following files:
download_statusbar-0.9.6.1-fx.xpi
google-browsersync.xpi
customizegoogle-0.71-fx+sm.xpi
bettergmail2_0.3.4.xpi
bettergcal_0.2.2.xpi
bettergreader_0.2.2.xpi
adblock-0.5.3.043-fx+fl+mz+ns.xpi
dragdropupload-1.5.25-fx.xpi
firebug1.0-current.xpi
firebug-1.1.0b12.xpi
gears-osx-opt.xpi
piclens-mac-release-1.6.2.1659.xpi
install.rdf

I can then drag VicsAddons.xpi to a Firefox window, and all add-ons and themes are installed in one fell swoop (restarting Firefox still required, unfortunately).

Note that since Firebug has both its current and beta versions on the same web page, maddon.py adds them both, which could be problematic. I could reference the exact desired .xpi version, but this loses the benefit of retrieving the latest version when run. Ah, trade-offs.

Here is the help.

usage: maddon.py [options] <file_or_directory> [...]

Create a multiple-item XPI. The <file_or_directory> argument(s) can be any of the following:

.(xpi|jar) file - added directly to bundle
URL, .webloc file
- if ends with '.(xpi|jar)', will be downloaded and add to bundle;
otherwise, the web page is scanned for links ending with '.(xpi|jar)'
directory - scanned for files satisfying any of the above requirements
text file - each line is scanned as if it were given as a parameter. Lines beginning
with '"', '#', '!', or ':' are considered comments

No comments:

Post a Comment