Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install WebExtension that developed by myself to Firefox Nightly?

I already know the way to temporarily install an add-on for debugging. However, I want to install it persistently. I do not want to upload it to AMO, because I've developed it for use by myself only.

How do I install it on Firefox Nightly?

Browser: Firefox Nightly 56a1
OS: macOS 10.12.5

Edit

I attempted Andrew's way while referring to Getting started with firefox-addon, but an error occurred (This add-on could not be installed because it appears to be corrupt.), despite that temporary installation was successful.
Why did installation fail only when installing it from Install Add-on from File...?

Source code is here https://github.com/KiYugadgeter/webext

Edit2:

The following is Error message on browser console.

1497764354857   addons.xpi  WARN    Invalid XPI: Error: Cannot find id for 

addon /
Users/username/jsworks/webextensions/stacknotifier/something.xpi (resource://gre/modules/addons/XPIInstall.jsm:1642:17) JS Stack trace: [email protected]:1642:17 <
async*[email protected]:2122:13 < async*[email protected]:4820:12 < [email protected]:3437:5 < [email protected]:297:12 <
promiseCallProvider/<@AddonManager.jsm:321:53 < [email protected]:390:5 <
[email protected]:320:10 < getInstallForFile/<@AddonManager.jsm:1856:29
< async*[email protected]:1854:13 < [email protected]:
3560:7 < doCommand/<@extensions.js:1472:13

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.hostPort]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://gre/modules/PopupNotifications.jsm :: PopupNotifications_refreshPanel/< :: line 806"  data: no]
like image 542
KiYugadgeter Avatar asked Jun 14 '17 06:06

KiYugadgeter


2 Answers

Recent versions of Firefox require you to sign the extension before you can permanently install it. To get your extension signed you don't have to publish it. All you need is a tool called web-ext. Then you can simply run this from your terminal:

web-ext sign --api-key=$AMO_JWT_ISSUER --api-secret=$AMO_JWT_SECRET

Getting started with web-ext:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Getting_started_with_web-ext

web-ext sign:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/web-ext_command_reference#web-ext_sign

Getting your AMO_JWT_ISSUER and AMO_JWT_SECRET:
https://addons.mozilla.org/en-US/developers/addon/api/key/

In short:

  • Downlaod and Install NodeJS
  • Open a new terminal and run npm install --global web-ext
  • Go to api key site and get your AMO_JWT_ISSUER and AMO_JWT_SECRET
  • Open a new terminal, go into the folder which contains your extension sources and run

    web-ext sign --api-key=xxxx:xxxxxxx:xxx --api-secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    
like image 156
Forivin Avatar answered Sep 29 '22 10:09

Forivin


Your error is: Invalid XPI: Error: Cannot find id for addon

Quoting WebExtension documentation:

When do you need an Add-on ID?

  • If you are loading the add-on from it's XPI file, are not loading it temporarily using about:debugging and it is not signed.
  • ...

This is your situation; as such, you need to fill out the applications.gecko.id key in the manifest. This plays the similar role as setting key key in Chrome (in Chrome, the ID of a packed extension is a hash of the key field).

Alternatively (and possibly preferably), you can sign your XPI as indicated by Forivin's answer, because loading unsigned WebExtensions is only possible in Nightly. That would require interaction with AMO - but there's no requirement to host there.

like image 26
Xan Avatar answered Sep 29 '22 09:09

Xan