Firefox add-ons: how to install my own local add-on (extension) permanently in Firefox?
Asked Answered
C

4

26

I have my own browser extension with some personal website customizations. Works fine in Chrome, but doesn't work in Firefox.

Unlike Chrome, it seems Firefox can't install unpacked extensions or add-ons. Only in debug mode I can do Load Temporary Add-on, select the folder with my extension, and that works OK. 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:

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. 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. Loading that extension in Firefox give the error above.

For your reference here is my 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:

// this file is intentionally left blank

Again: works fine in Chrome, works fine in Firefox when loading as temporary add-on in debug mode (i.e. by loading the files, in the open dialog I select the manifest.json file). But loading the .xpi to install this extension permanently results in the "appears to be corrupt" error.

FYI: I'm using the latest versions of Chrome and Firefox on macOS 10.15.5.

For testing purposes, here is the exact test.xpi file I created, but packing it manually as decribed above will give the same result.

Chasitychasm answered 6/6, 2020 at 19:48 Comment(2)
works fine in Firefox when loading as temporary add-on... You mean it installs ok, but this addon does nothing, so you can't say that it works fine.Steam
@Steam Obviously I meant the loading / installation works fine.Chasitychasm
L
14

Ran into the exact same problem the other day..

To get my personal xpi to install permanently (under Firefox for 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)

  • add an explicit id to browser_specific_settings section in the manifest

For example:

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

Hope this helps!

Loblolly answered 8/6, 2020 at 6:17 Comment(9)
Thanks, after adding an id it now complains about the xpi being unverified. Regarding the thread you linked on how to disable signature checking, which answer would that be, exactly? czerny's answer didn't work (I don't have nightly or developer build) and the 2nd answer by Makyen seems ridiculously complex. Is there a quick and easy way to (temporarily) disable signature checking by any chance?Chasitychasm
I meant: about:config -> xpinstall.signatures.required = false Just to clarify, Im using Firefox for Linux. The standard downloaded from Mozilla. Also, the addons seems to be verified every time they are loaded (browser restart), so unfortunatelly the verification will need to be disabled permanently.Loblolly
Ah OK, no unfortunately that doesn't work here in Firefox 77 on macOS.Chasitychasm
Meanwhile Firefox seems to silently ignore when the user changes that setting. But it still works in e.g. Firefox Developer, see here.Halifax
how to update addon after local change? You have to pack add on after every change?Sandon
I'm using Firefox Developer Edition with xpinstall.signatures.required = false and exactly the same file as OP, plus your addition to manifest.json. It still says that the extension is corrupt. I'm using 7z with DEFLATE in a .zip archive. then renaming it to .xpi, but I'm still getting the error. @LoblollyRothko
Same issue here, I can load from .zip my local extension, but I can't load it unpacked. So it makes a lot of problems during development, since I need to debug the unpacked version.Lefebvre
This add-on could not be installed because it appears to be corrupt, doesn't workTericaterina
Installed in Firefox Developer edition (blue logo), xpinstall.signatures.required = false, xpinstall.whitelist.required = false, packed extension files into .zip, renamed into .xpiTericaterina
U
11

Did you try the web-ext tool and sign your add-on? You can use the Web-ext CLI tool to sign and install on your firefox.

Unwell answered 12/7, 2020 at 19:2 Comment(1)
Not sure if this has changed since 2020, but this now throws an error if you run web-ext sign by itself: Missing required arguments: api-key, api-secret, channel, with api-key and api-secret apparently sourced from addons.mozilla.org. Faking them throws a WebExtError: Upload failed: Unauthorized response.Addams
R
0

It is possible to just upload the addon to Mozilla Developer Hub, and they sign it officially. One has to run web-ext build from the addon folder, then upload the zip to the Hub. There is an automatic check, which completed in ~2 minutes for me, then I could just download the signed .xpi file.

Risible answered 2/4, 2023 at 16:22 Comment(0)
V
0

When trying to upload the addon to Mozilla for verification, I encountered the error, that the manifest.json was missing. Turns out, the file has to be in the root of the zip.

.. 
  yourAddon.zip
      manifest.json
      OptionalFolder/
          yourScript.js
      anotherScript.js

I tried packing it like that and adding it without verifying it (read lukacs answer for more information) and it worked.

Vietnamese answered 18/10, 2023 at 13:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.