Anyways, I updated to Firefox 3 when RC1 came out. I figure, “hey, it’s about to be released, extensions will work soon”. Then they go and back down. Me being as a developer as I am (generally lazy), I didn’t want to uninstall. Plus there’s the fact that the new autocomplete is pretty shiny.
I quickly learned that you could simply swap out the version number in the manifest to allow the addon to load. Granted, this can cause problems, but I’m willing to face problems as long as I can at least *try* to use Firebug :)
So this morning I drafted up a quick Python script which will actually run through a list of files and update the min/maxVersion fields as needed. I plan to throw up a quick web form this weekend to let you do it by simply pointing to the URL or uploading the .XPI and then installing the updated one.
Update: I went ahead and created a little webpage which executes the Python script and feeds the updated extension back to you. Check out the Firefox Addon Version Converter.
</p>"""Firefox Addon Version UpdaterCreated by David Cramer (http://www.davidcramer.net/)Use this to update the minVersion and/or maxVersion fields in the firefoxextension manifest files.e.g. convert extension to 3.xpython convert.py <file.xpi> --max-version=3.*"""importzipfileimportreMIN_VERSION=FalseMAX_VERSION='3.*'regexp=r'(?m)<em:id>{%(target_id)s}</em:id>\s*<em:minVersion>(.+)</em:minVersion>\s*<em:maxVersion>(.+)</em:maxVersion>'deftweak_addon_version_reqs(filepath,min_version=None,max_version=None):ifmin_versionisNone:min_version=MIN_VERSIONifmax_versionisNone:max_version=MAX_VERSIONarchive=zipfile.ZipFile(filepath,'a')forfnameinarchive.namelist():iffname[-4:]=='.rdf':data=archive.read(fname)# FireFoxtarget_id='ec8030f7-c20a-464f-9b0e-13a3a9e97384'opts={'target_id':target_id,'min_version':min_versionor'\g<1>','max_version':max_versionor'\g<2>',}data=re.sub(regexp%opts,r'<em:id>{%(target_id)s}</em:id>' \
'<em:minVersion>%(min_version)s</em:minVersion>' \
'<em:maxVersion>%(max_version)s</em:maxVersion>'%opts,data)archive.writestr(fname,data)breakarchive.close()defmain():fromoptparseimportOptionParserusage="usage: %prog [options] files"parser=OptionParser(usage)parser.add_option("-b","--min-version",dest="min_version",help="modify minVersion field")parser.add_option("-e","--max-version",dest="max_version",help="modify maxVersion field")options,files=parser.parse_args()ifnotfiles:parser.error("you must specify at least one file")forfnameinfiles:tweak_addon_version_reqs(fname,options.min_version,options.max_version)</p>if__name__=='__main__':main()