Question

I use simple-prefs module to configure addon settings. How can I programmatically open addon's settings page?

Was it helpful?

Solution

We do this in a test add-on here

There is more code there than you need though, so the shorter version is:

const self = require('sdk/self');
const tabs = require('sdk/tabs');

tabs.open({
  url: 'about:addons',
  onReady: function(tab) {
    tab.attach({
      contentScriptWhen: 'end',
      contentScript: 'AddonManager.getAddonByID("' + self.id + '", function(aAddon) {\n' +
                       'unsafeWindow.gViewController.commands.cmd_showItemDetails.doCommand(aAddon, true);\n' +
                     '});\n'
    });
  }
});

In words, this opens the about:addons page in a new tab, waits for it to load, then opens the details page for your add-on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top