4

I been working on a firefox extension project and now I'm stuck on this,

var abc = 123;

var pageMod = require("page-mod");
pageMod.PageMod({
  include: "*",
  contentScriptWhen: 'ready',
  contentScript:  'var newabc = 456;',
});

where abc is a global variable and newabc is a variable within the contentScript.

How do I make abc = newabc ?

Thanks!!

1
  • Don't have experience using FF extensions, but have you tried changing contentScript to be 'var newabc = 456; abc = newabc;'? Probably a dumb suggestion, I'm just not familiar with FF extension scoping.
    – mway
    Mar 11, 2011 at 19:40

1 Answer 1

4

For the Addon-SDK v1.0b3's PageMod API:

var abc = 123;

var pageMod = require("page-mod");
pageMod.PageMod({
  include: "*",
  contentScriptWhen: 'ready',
  contentScript:  'var newabc = 456;postMessage(newabc);',
  onAttach: function onAttach(worker) {
    worker.on('message', function(newabc) {
      abc = newabc;
    });
  }
});
1
  • Hi thanks,I was new to SO, didn't know much about how it works at the time. Answer has been marked.
    – eastboundr
    Nov 17, 2011 at 17:35

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.