Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7557217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:04:27+00:00 2026-05-30T12:04:27+00:00

I’m currently trying to add some preferences to a Firefox add-on. To do so,

  • 0

I’m currently trying to add some preferences to a Firefox add-on. To do so, I’m playing with the new “simple-prefs” module. (Simple-Prefs on the Mozilla Blog)

The documentation is not very detailed and I face some problems understanding how I can retrieve the value attached to an option and export it to a JS script present in my data folder.

Let’s say that I have only one optional setting in my addon, a boolean one, then my packages.json will look like this:

{
  "name": "test",
  ...
  "preferences": [{
    "type": "bool",
    "name": "option1",
    "value": true,
    "title": "Desc Option 1" 
  }]
}

Here is my main.js file [UPDATED]:

var pageMod = require("page-mod");
const data = require("self").data;
const prefSet = require("simple-prefs");  //Simple-prefs module

var option1 = prefSet.prefs.option1;     //get the value for option1

function onPrefChange(prefName) {        //Listen for changes

   var prefName = prefSet.prefs[prefName];
                      }

prefSet.on("option1", onPrefChange);


exports.main = function() {
  pageMod.PageMod({ 
    include: ["https://mail.google.com/*","http://mail.google.com/*"],
    contentScriptWhen: 'ready',
    contentScriptFile: [data.url("jquery.js"),data.url("script.js")],
    onAttach: function(worker)
        {
      worker.postMessage( option1 );
        }
    });
}

How can I retrieve the value attached to “option1” and export it in order to call it in my “script.js” file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:04:29+00:00Added an answer on May 30, 2026 at 12:04 pm

    As usually, content scripts don’t have access to the API – they can only receive messages from your extension’s scripts. Here you would do:

    pageMod.PageMod({ 
      include: ["https://mail.google.com/*","http://mail.google.com/*"],
      contentScriptWhen: 'ready',
      contentScriptFile: [data.url("jquery.js"),data.url("script.js")],
      onAttach: function(worker)
      {
        worker.postMessage(backtop);
      }
    });
    

    And in the content script you would have the following code:

    self.on("message", function(data)
    {
      alert("Received option value: " + data);
    });
    

    This message arrives asynchronously meaning that your content script won’t know the option value initially – but that’s how content scripts work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.