安装附加组件时出错

发布于 2024-12-17 10:32:26 字数 588 浏览 2 评论 0原文

我正在尝试安装具有以下目录结构的示例扩展。

myexample
- install.rdf
- chrome.manifest
- content
-- myexample.js
-- myexample.xul

文件 chrome.manifest 包含:

内容 myexample chrome/content/

覆盖 chrome://browser/content/browser.xul chrome://myexample/content/myexample.xul

这是非常简约的扩展。

我从中创建了一个 zip 文件:

zip -r myexample.xpi myexample/

在 Firefox 中安装时 Tools ->;附加组件 ->从文件安装附加组件... ->选择 myexample.xpi 它写道:

无法安装此附加组件,因为它似乎已损坏。

我有什么问题吗?

I'm trying to install my example extension which has the following directory structure.

myexample
- install.rdf
- chrome.manifest
- content
-- myexample.js
-- myexample.xul

The file chrome.manifest contains:

content myexample chrome/content/

overlay chrome://browser/content/browser.xul
chrome://myexample/content/myexample.xul

It's pretty minimalist extension.

I created a zip file from it:

zip -r myexample.xpi myexample/

When installing it in Firefox Tools -> Add-ons -> Install Add-on from file ... -> choose myexample.xpi it writes:

This add-on could not be installed because it appears to be corrupt.

Did I something wrong?

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

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

发布评论

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

评论(1

踏雪无痕 2024-12-24 10:32:26

您的问题标题具有误导性 - 您的 chrome.manifest 没有任何问题。此错误消息意味着 Firefox 在您的附加组件的顶层找不到 install.rdf 文件。如果您运行 unzip -l myexample.xpi 您将看到如下内容:

  Length     Date   Time    Name
 --------    ----   ----    ----
                            myexample/
                            myexample/install.rdf
                            myexample/chrome.manifest
                            myexample/content/

如您所见,您压缩的所有文件都已放入 myexample/ 子目录中,而不是位于档案的顶层。要获得正确的结果,您需要运行以下命令:

cd myexample
zip -r ../myexample.xpi *
cd ..

The title of your question is misleading - there is nothing wrong with your chrome.manifest. This error message rather means that Firefox couldn't find install.rdf file at the top level of your add-on. If you run unzip -l myexample.xpi you will see something like this:

  Length     Date   Time    Name
 --------    ----   ----    ----
                            myexample/
                            myexample/install.rdf
                            myexample/chrome.manifest
                            myexample/content/

As you see, all files you zipped have been put into the myexample/ subdirectory instead of being at the top level of the archive. To get the correct result you need to run the following commands:

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