重新打包和/或修改现有的Firefox扩展XPI [英] Re-packaging and/or modifying an existing Firefox extension XPI
问题描述
我是一名高级用户,拥有一些程序员技能,但是我已经安装了一些Firefox附加组件,并且想在原始代码中添加一些额外的代码行。但是我只有 .xpi 文件。
我知道它可以通过任何zip实用程序打开。但是当我改变那里的东西的时候它不起作用。
它将 .js 文件存储在 CONTENT 文件夹中。有一个输出到文件的功能,我想格式化一个字符串有点被保存到一个文件。
你可以不提到开始这个问题,但有主要目标和问题:如何重新编译或应用任何更改到 .js 文件在安装的 .xpi 扩展?任何方式来升级它们。
$ b
附件:
$ b
然而有一些缺陷: 这是正确的压缩: 这不正确的压缩(通过使用OSX压缩菜单项产生): (除了
META-INF
文件夹所示。修改东西当然会使签名无效。只需删除文件夹即可使(修改后的)扩展名无符号地重新签名。 /some-addon-folder/install.rdf
而不是 /install.rdf
。请确保不要压缩外部文件夹,只是其中的文件和子文件夹。
$ unzip -l http_request_logger-0.1-fx.xpi
存档:http_request_logger-0.1-fx.xpi
长度日期时间名称
-------- - - ---- ----
240 07-29-11 11:45 chrome.manifest
0 07-29-11 11:42组件/
1558 07-29- 11 11:47 components / httpRequestLogger.js
1021 07-30-11 12:39 install.rdf
-------- -------
2819 4文件
$ unzip -l http_request_logger-0.1-fx.zip
存档:http_request_logger-0.1-fx.zip
长度日期时间名称
-------- ---- ---- ----
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-1 4一点54 __MACOSX /
0 14年5月16日1时54分__MACOSX / http_request_logger-0.1-FX /
187 11年7月29日11时45 __MACOSX / http_request_logger-0.1-FX /._铬.manifest的
0 11年7月29日11时42 http_request_logger-0.1-FX /组件/
1558 11年7月29日11时四十七http_request_logger-0.1-FX /组件/ httpRequestLogger.js
0,14年5月16日一时54 __MACOSX / http_request_logger-0.1-FX /组件/
187 11年7月29日11时47 __MACOSX / http_request_logger-0.1-FX /组件/._ httpRequestLogger.js
1021 11年7月30日12时39 http_request_logger-0.1-FX / install.rdf的
187 11年7月30日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个文件
__ MACOSX
废话,它是 http_request_logger- 0.1 -fx / install.rdf
now)
我推荐MEND还阅读建立一个扩展开发环境,尤其是位关于代理文件。 ;)
说到SDK附加组件(如 harness-options.json
文件),重新压缩可能不起作用。根据 .xpi
内容重新生成package.json和目录结构可能会更好,并使用SDK cfx
工具来建立一个新的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 file.
I know it can be opened by any zip utility. But it doesn't work when I change something in there. It stores .js file in CONTENT folder. There is an output-to-file function and I want to format a string a little bit that is being saved into a file.
You can to not mention the beginning of the question but there is the main goal and question: How to recompile or apply any changes to .js files in installed .xpi extensions? Any ways to upgrade them.
Add-ons:
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 Date Time Name
-------- ---- ---- ----
240 07-29-11 11:45 chrome.manifest
0 07-29-11 11:42 components/
1558 07-29-11 11:47 components/httpRequestLogger.js
1021 07-30-11 12:39 install.rdf
-------- -------
2819 4 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.
这篇关于重新打包和/或修改现有的Firefox扩展XPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!