简体   繁体   English

Firefox 附加组件:如何在 Firefox 中永久安装我自己的本地附加组件(扩展)?

[英]Firefox add-ons: how to install my own local add-on (extension) permanently in Firefox?

I have my own browser extension with some personal website customizations.我有自己的浏览器扩展和一些个人网站定制。 Works fine in Chrome, but doesn't work in Firefox.在 Chrome 中工作正常,但在 Firefox 中不起作用。

Unlike Chrome, it seems Firefox can't install unpacked extensions or add-ons.与 Chrome 不同,Firefox 似乎无法安装解压缩的扩展程序或附加组件。 Only in debug mode I can do Load Temporary Add-on , select the folder with my extension, and that works OK.只有在调试模式下,我才能使用我的扩展名执行Load Temporary Add-on , select 文件夹,并且可以正常工作。 Except that's just temporary.除了那只是暂时的。

When I pack the extension by putting the files in a.zip (not within a subdirectory or anything, the archive just directly contains the files) and rename it to.xpi, and then choose Install Add-on from file and select my.xpi, it says:当我通过将文件放入 a.zip (不在子目录或任何内容中,存档直接包含文件)来打包扩展名并将其重命名为.xpi,然后选择Install Add-on from file插件, 它说:

The add-on downloaded from this site could not be installed because it appears to be corrupt.无法安装从该站点下载的加载项,因为它似乎已损坏。

While troubleshooting, I made a minimal dummy extension which doesn't do anything, consisting only of a manifest.json and dummy.js file.在进行故障排除时,我做了一个不做任何事情的最小虚拟扩展,仅包含manifest.jsondummy.js文件。 Then pack that from the command line using 7z a -tzip test.xpi in that directory, which creates my zip file called test.xpi containing the two files.然后在该目录中使用7z a -tzip test.xpi ,这将创建我的名为test.xpi的 zip 文件,其中包含这两个文件。 Loading that extension in Firefox give the error above.在 Firefox 中加载该扩展会给出上述错误。

For your reference here is my manifest.json:我的 manifest.json 供您参考:

{
  "manifest_version": 2,
  "name": "Test Extension",
  "version": "1.0",
  "description": "Dummy Text Extension",
  "content_scripts": [
    {
      "matches": [ "*://*/" ],
      "js": ["dummy.js"]
    }
  ]
}

And the content of dummy.js is: dummy.js 的内容是:

// this file is intentionally left blank

Again: works fine in Chrome, works fine in Firefox when loading as temporary add-on in debug mode (ie by loading the files, in the open dialog I select the manifest.json file).再次:在 Chrome 中工作正常,在调试模式下作为临时加载项加载时在 Firefox 中工作正常(即通过加载文件,在打开的对话框中我 select manifest.Z466DEEC76ECDF5FCA6D38571F6324D 文件)。 But loading the.xpi to install this extension permanently results in the "appears to be corrupt" error.但是加载.xpi 以永久安装此扩展会导致“似乎已损坏”错误。

FYI: I'm using the latest versions of Chrome and Firefox on macOS 10.15.5.仅供参考:我在 macOS 10.15.5 上使用最新版本的 Chrome 和 Firefox。

For testing purposes, here is the exact test.xpi file I created, but packing it manually as decribed above will give the same result.出于测试目的,这里是我创建的确切的test.xpi文件,但是如上所述手动打包它会得到相同的结果。

Ran into the exact same problem the other day..前几天遇到了完全相同的问题..

To get my personal xpi to install permanently (under Firefox for Linux 77.0.1):要让我的个人 xpi 永久安装(在 Firefox 下,对于 Linux 77.0.1):

  • had to disable extension signing about:config , xpinstall.signatures.required = false (unfortunatelly this will need to stay, because signatures seems to be verified on every browser start)必须禁用扩展签名about:configxpinstall.signatures.required = false (不幸的是,这需要保留,因为签名似乎在每次浏览器启动时都会得到验证)

  • add an explicit id to browser_specific_settings section in the manifest向清单中的browser_specific_settings部分添加显式 id

For example:例如:

"browser_specific_settings": {
  "gecko": {
    "id": "blahblah@blah"
  }
}

Hope this helps!希望这可以帮助!

Did you try the web-ext tool and sign your add-on?您是否尝试了 web-ext 工具并签署了您的附加组件? You can use the Web-ext CLI tool to sign and install on your firefox.您可以使用 Web-ext CLI 工具在 firefox 上进行签名和安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM