1

I have an addon using simple-prefs. The addon modifies some webpages using PageMod.

I would like to add a link to these webpages, that will open the addon options. Basically, what I need, is a Firefox version of chrome.extension.getURL('options.html'); used in Chrome.

I have tried some old methods. For example using URL like this: addons://detail/ADDON_ID/preferences. Or this method from official documentation. But none of them seem to work.

How do I do that? Is it even possible?

2
  • Something like this? github.com/Noitidart/l10n/tree/html-options Commented Mar 30, 2015 at 15:18
  • @Noitidart No. My addon uses SDK, is built using JPM and the options page is generated by simple-prefs module. Commented Mar 31, 2015 at 13:50

1 Answer 1

3

First off, you can't open it directly from the content script. You'll have to send a message from your content script to your extension using the port API, which would look something like this in your content script:

self.port.emit("openPrefs");

In your add-on module where you have the reference to your PageMod object (I assume it's saved in the pageMod variable) you'd then open the preferences page using the (undocumented) sdk/preferences/utils module:

var self = require("sdk/self");
var { open } = require("sdk/preferences/utils");
pageMod.port.on("openPrefs", function() {
  open({ id: self.id });
});
Sign up to request clarification or add additional context in comments.

2 Comments

It worked. Thank you! For the future reference, how can I learn about the undocumented features in Firefox SDK? Where did you learn it?
I am a lot in the #jetpack channel on irc.mozilla.org, where developers also give tips if you have issues and they are around. Further I look at the source code (github.com/mozilla/addon-sdk).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.