Skip to content

Instantly share code, notes, and snippets.

@amit08255
Last active October 27, 2021 10:02
Show Gist options
  • Save amit08255/2ddd28fd5fcd97949547241cb7012375 to your computer and use it in GitHub Desktop.
Save amit08255/2ddd28fd5fcd97949547241cb7012375 to your computer and use it in GitHub Desktop.
Installing custom addon in firefox

1. Disabling signing required in config

  • Type - about:config in address bar and press enter.
  • Search for xpinstall.signatures.required and double click to disable

2. Signing addon file

  • First select all addon files and convert to .zip file and rename extension to .xpi
  • Initialize the nodejs project in your computer using command npm init.
  • Install sign-addon package using command npm install sign-addon.
  • Now use below NodeJS script to sign addon (to get API secret and API key, visit - https://addons.mozilla.org/en-US/developers/addon/api/key/
var { signAddon } = require('sign-addon');

signAddon({
  // Required arguments:

  xpiPath: '/path/to/your/addon.xpi',
  version: '0.0.1',
  apiKey: 'Your JWT issuer',
  apiSecret: 'Your JWT secret',

  // Optional arguments:

  // The release channel (listed or unlisted).
  // Ignored for new add-ons, which are always unlisted.
  // Default: most recently used channel.
  channel: undefined,
  // Save downloaded files to this directory.
  // Default: current working directory.
  downloadDir: undefined,
  // Number of milliseconds to wait before aborting the request.
  // Default: 15 minutes.
  timeout: undefined,
  // Optional proxy to use for all API requests,
  // such as "http://yourproxy:6000"
  // Read this for details on how proxy requests work:
  // https://github.com/request/request#proxies
  apiProxy: undefined,
  // Optional object to pass to request() for additional configuration.
  // Some properties such as 'url' cannot be defined here.
  // Available options:
  // https://github.com/request/request#requestoptions-callback
  apiRequestConfig: undefined,
  // Optional override to the number of seconds until the JWT token for
  // the API request expires. This must match the expiration time that
  // the API server accepts.
  apiJwtExpiresIn: undefined,
  // Optional override to the URL prefix of the signing API.
  // The production instance of the API will be used by default.
  apiUrlPrefix: 'https://addons.mozilla.org/api/v4',
})
  .then(function (result) {
    if (result.success) {
      console.log('The following signed files were downloaded:');
      console.log(result.downloadedFiles);
      console.log('Your extension ID is:');
      console.log(result.id);
    } else {
      console.error('Your add-on could not be signed!');
      console.error('Error code: ' + result.errorCode);
      console.error('Details: ' + result.errorDetails);
    }
    console.log(result.success ? 'SUCCESS' : 'FAIL');
  })
  .catch(function (error) {
    console.error('Signing error:', error);
  });
  • Now just drag and drop the signed xpi file in Firefox to install.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment