How to pass ContentScript data to a global module variable in JavaScript?

I was 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 inside contentScript.

How to make abc = newabc?

Thanks!!

+4
source share
1 answer

For Addon-SDK v1.0b3 API PageMod :

 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; }); } }); 
+4
source

Source: https://habr.com/ru/post/1342948/


All Articles