0

I occasionally develop small custom Web Extensions to Firefox, e.g. for redirecting local language urls to original language urls.

I don't want to bother signing and registering these personal extensions with Mozilla (and doing this again when I change a single line of code).

Problem

Mozilla decided to make this case a hell, they don't provide a way to load such extensions permanently nor automatically. Instead a button must be used each time the application is launched:

enter image description here
Source

There is a possibility to use a node.js application (web-ext), but I don't want to install node.js for this single occasional need either.

Though I'll never tank Mozilla enough for trying to prevent me doing crazy things to myself, I'd like to use the API call behind their Load Temporary Add-on to re-automate unsigned extension loading when Firefox is launched, using a configuration file with a list of extensions to load.

Possible solution

The API call they use is installTemporaryAddon from AddonManager.jsm:

  /**
   * Installs a temporary add-on from a local file or directory.
   * @param  aFile
   *         An nsIFile for the file or directory of the add-on to be
   *         temporarily installed.
   * @return a Promise that rejects if the add-on is not a valid restartless
   *         add-on or if the same ID is already temporarily installed.
   */
  installTemporaryAddon: function(aFile) {
    if (!gStarted)
      throw Components.Exception("AddonManager is not initialized",
                                 Cr.NS_ERROR_NOT_INITIALIZED);

    if (!(aFile instanceof Ci.nsIFile))
      ...

Source

The solution is therefore very simple: Just call this method with the folder containing the extension. But I don't know how to use an API on Firefox, knowing this call must likely be done with some privileges.

Question

Is there someone with appropriate knowledge who can give me some guidance on how to call the method, e.g. when Firefox starts?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.