Re-packaging And/or Modifying An Existing Firefox Extension Xpi
I am an advanced user and have some programmer skills but I have installed some firefox add-on and I'd like to add some extra code line to original code. But I've only got .xpi fil
Solution 1:
Essentially you just zip up stuff again (non-SDK add-ons). And those add-ons you linked are non-SDK add-ons.
However there are some pitfalls:
- The extension might have been digitally signed, as indicated by the presence of a
META-INF
folder. Modifying stuff will of course invalidate the signature. Just remove the folder to make the (modified) extension unsigned again. - Quite often people actually zip up the outer folder. I.e. the resulting zip (
.xpi
) then contains/some-addon-folder/install.rdf
instead of just/install.rdf
. Make sure to not zip the outer folder, just the files and subfolders within. - Some zip tools produce zip files that are essentially broken; broken enough to be rejected by Firefox but not broken enough for other zip utilities to break. Make sure the zip if valid and if in doubt switch the zip utility you use.
- Also remember to actually ZIP stuff as opposed to 7zip, rar, tar.gz, or whatever. ;)
This is correctly zipped:
$ unzip -l http_request_logger-0.1-fx.xpi
Archive: http_request_logger-0.1-fx.xpi
Length DateTime Name
-------- ---- ---- ----24007-29-1111:45 chrome.manifest
007-29-1111:42 components/155807-29-1111:47 components/httpRequestLogger.js
102107-30-1112:39 install.rdf
-------- -------28194 files
This is not correctly zipped (produced by using the OSX compress menu item):
$ unzip -l http_request_logger-0.1-fx.zip
Archive: http_request_logger-0.1-fx.zip
Length Date Time Name
-------- ---- ---- ----
0 05-16-14 01:54 http_request_logger-0.1-fx/
240 07-29-11 11:45 http_request_logger-0.1-fx/chrome.manifest
0 05-16-14 01:54 __MACOSX/
0 05-16-14 01:54 __MACOSX/http_request_logger-0.1-fx/
187 07-29-11 11:45 __MACOSX/http_request_logger-0.1-fx/._chrome.manifest
0 07-29-11 11:42 http_request_logger-0.1-fx/components/
1558 07-29-11 11:47 http_request_logger-0.1-fx/components/httpRequestLogger.js
0 05-16-14 01:54 __MACOSX/http_request_logger-0.1-fx/components/
187 07-29-11 11:47 __MACOSX/http_request_logger-0.1-fx/components/._httpRequestLogger.js
1021 07-30-11 12:39 http_request_logger-0.1-fx/install.rdf
187 07-30-11 12:39 __MACOSX/http_request_logger-0.1-fx/._install.rdf
187 05-16-14 01:54 __MACOSX/._http_request_logger-0.1-fx
-------- -------
3567 12 files
(Aside from the __MACOSX
crap, it is http_request_logger-0.1-fx/install.rdf
now)
I recommend you also read Setting up an extension development enviroment, in particular the bits about the proxy file. ;)
When it comes to SDK add-ons (as indicated by the presence of a harness-options.json
file), re-zipping may or not work. It might be better to just reproduce a package.json and directory structure based on the .xpi
contents and use the SDK cfx
tool to build a new XPI.
Post a Comment for "Re-packaging And/or Modifying An Existing Firefox Extension Xpi"