0

In Firefox, is there a way to open the add-on's own options page within about:addons through a button in the add-on? (Not just the options.html page by itself, but within the about:addons page, the same one that you can get to when pressing "more" beside the description of the add-on).

I got this:

function OpenOptionsMenu() {
  browser.tabs.create({
  url: "???"
});

But, I have no idea what to put as the URL.

I found this: browser.runtime.getURL('/options.html'), but that will only get the options page by itself.

Makyen
  • 31,849
  • 12
  • 86
  • 121
8176135
  • 3,755
  • 3
  • 19
  • 42

2 Answers2

0

There is a function specifically for this:

browser.runtime.openOptionsPage()

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/openOptionsPage

However, opening the options page in a separate tab is a perfectly valid UI choice.

Daniel Herr
  • 19,083
  • 6
  • 44
  • 61
  • You nija'ed me by a few seconds. If you want to put the information about `open_in_tab` into your answer, I'll delete mine. – Makyen Feb 09 '17 at 05:23
0

The command to do this is:

chrome.runtime.openOptionsPage();

or

browser.runtime.openOptionsPage();

This will open the options page displayed as it would normally be if the user clicked on the Options button from about:addons. If it is supposed to be displayed within about:addons (i.e. open_in_tab not specified in options_ui) then it will be displayed in about:addons.

If you did specify open_in_tab in the options_ui key within your manifest.json, then it will be opened in a separate tab. With open_in_tab specified, there no way to open it within about:addons. If open_in_tab is not specified you can open it in a tab, or window, should you choose to do so.

Community
  • 1
  • 1
Makyen
  • 31,849
  • 12
  • 86
  • 121