编辑现有的 Firefox 插件

发布于 2024-12-05 09:13:06 字数 1286 浏览 1 评论 0原文

对于我正在从事的项目之一,我必须使用 DOM Inspector 来调试 Firefox 扩展。

DOM 检查器的问题在于,它只向您显示代码下方的浏览器,无法分离浏览器或并排显示代码部分或浏览器。

它对我不起作用,因为我正在调试的插件有一个很大的 xul 覆盖层,并且有问题的区域位于底部,因此没有物理方法可以查看该区域的代码以及该区域本身。

所以我决定修改 DOM Inspector 本身,将浏览器放置在代码编辑器的一侧。

以下是我执行的步骤:

  1. 从配置文件目录中获取现有的 xpi 文件。
  2. 改成zip了。
  3. 进入内部并使用 jar -xf 提取 inspector.jar
  4. 进入 inspectorOverlay.xul 并更改 是一个 hbox。 (这应该足以水平定位这两个窗口。)
  5. 然后我使用 jar cf 重新创建了 jar 文件。
  6. 压缩目录,确保名称相同,并将扩展名更改回 xpi。

但是,当我尝试运行它时,我收到以下警告:

Warning: WARN addons.xpi: Add-on is invalid: [Exception... "Component returned failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) [nsIZipReader.getInputStream]"  nsresult: "0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)"  location: "JS frame :: resource://gre/modules/XPIProvider.jsm :: loadManifestFromZipReader :: line 740"  data: no]
Source File: resource://gre/modules/XPIProvider.jsm
Line: 740

Warning: WARN addons.xpi: Could not uninstall invalid item from locked install location
Source File: resource://gre/modules/XPIProvider.jsm
Line: 2042

我的问题是 - 通常我还需要进行哪些其他更改才能正确解释 xpi?

For one of the projects I'm working on, I have to use DOM Inspector to debug a Firefox extension.

The problem with DOM inspector is that it only shows you the browser below the code, there's no way to detach the browser or out the code section or browser side by side.

It didn't work for me because the plugin I was debugging had a large xul overlay, and the problematic area was at the botton, so there's no physical way to see the code for the area as well as the area itself.

So I have decided to modify DOM Inspector itself to place browser to the side of the code editor.

Here are the steps I undertook:

  1. Took the existing xpi file from the profile directory.
  2. Changed it to be a zip.
  3. Went inside and extracted inspector.jar using jar -xf <filename>
  4. Went to inspectorOverlay.xul and changed <vbox id="bxInspectorMain"> to be an hbox. (This should be enough to position those two windows horizontally.)
  5. Then I recreated jar file using jar cf.
  6. Zipped the directory making sure that the name is the same and changed extension back to xpi.

However, when I try to run it, I get the following warnings:

Warning: WARN addons.xpi: Add-on is invalid: [Exception... "Component returned failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) [nsIZipReader.getInputStream]"  nsresult: "0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)"  location: "JS frame :: resource://gre/modules/XPIProvider.jsm :: loadManifestFromZipReader :: line 740"  data: no]
Source File: resource://gre/modules/XPIProvider.jsm
Line: 740

Warning: WARN addons.xpi: Could not uninstall invalid item from locked install location
Source File: resource://gre/modules/XPIProvider.jsm
Line: 2042

My question is - what other changes do I generally need to make for the xpi to be properly interpreted?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日久见人心 2024-12-12 09:13:07

@Luka,我想弗拉基米尔·帕兰特是正确的。为了避免修改现有项目的源代码时出现错误,我建议您在工作环境中工作。

编辑源代码的建议方法:

  1. 安装 Eclipse
  2. 安装 Xul booster (project / docs)
  3. 从 FF 配置文件中提取您的酸代码。
  4. 检查主文件夹和子文件夹的名称是否与提取的 .Zippy 文件(FF 扩展名)中给出的名称完全相同。
  5. 在XUL booster环境下的Eclipse中创建一个新项目:请使用与您的FF扩展主文件夹和子文件夹相同的名称。
  6. 然后,将提取的文件复制粘贴到 Eclipse 中的 XUL 项目中。
  7. 修改你的代码&解压为 .XPi 文件并安装在您的 FF 浏览器中。

这样您就可以避免任何类型的错误,因为所有内容都会自动分类(Chrome 文件夹、清单、install.rdf、did dies 等)。

注意:有一种修改源代码的高级方法,FF 浏览器将通过在 FF 扩展配置文件文件夹中设置环境来自动检测源代码的修改。

  1. 创建一个 bat 文件并找到您的项目文件夹路径,然后在 FF 扩展配置文件文件夹中输入您的扩展 ID。 (指南

@Luka, I guess Wladimir Palant is correct. To avoid error during the modification of source code of the existing project, I would suggest you to work in the working environment.

The suggested way to edit your source code:

  1. Install Eclipse
  2. Install Xul booster (project / docs)
  3. Extract your sour code from FF profile.
  4. Check the name of the main folder and subfolder as exactly given in you extracted .Zippy file (FF extension).
  5. Create a new project in Eclipse under XUL booster environment: please use the same name of your FF extension main folder and sub folder.
  6. Then, copy paster your extracted files to the XUL project in Eclipse.
  7. Modify your code & extract as .XPi file and Install in you FF browser.

This way you can avoid any kind of errors because everything will be classified automatically (Chrome folder, manifest, install.rdf, did dies etc).

Note: There is an advanced way of modifying source code and FF browser wil detect the modification of your source code automatically by setting the environment in your FF extension profile folder.

  1. Create a bat file and locate your project folder path and type your extension id inside the FF extension profile folder. (guide)
相守太难 2024-12-12 09:13:06

压缩目录,确保名称相同,并将扩展名更改回 xpi。

我猜你在这一步做错了什么。查看源代码,消息来自方法updateMetadata() - Firefox 注意到文件已更改并尝试再次读取 install.rdf。该文件应该位于 XPI 文件的顶层,但在您的情况下找不到它。重新打包文件后,也许 install.rdf 不再位于顶层。您可以使用 unzip 命令对其进行测试:

unzip -l [email protected]

它应该显示 XPI 文件的内容,包括 install.rdfchrome.manifest - 无需任何前置目录名称。

Zipped the directory making sure that the name is the same and changed extension back to xpi.

I guess that you did something wrong in this step. Looking at the source code, the message comes from method updateMetadata() - Firefox noticed that the file changed and tries to read in install.rdf again. That file should be at the top level of the XPI file but in your case it cannot be found. Maybe install.rdf is no longer at the top level after you repacked the file. You can test it with the unzip command:

unzip -l [email protected]

It should show the contents of the XPI file, including install.rdf and chrome.manifest - without any prepended directory name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文