我一直在开发一个firefox扩展项目,现在我已经坚持了这个,
var abc = 123;
var pageMod = require("page-mod");
pageMod.PageMod({
include: "*",
contentScriptWhen: 'ready',
contentScript: 'var newabc = 456;',
});
其中abc是全局变量,newabc是contentScript中的变量。
如何制作abc = newabc?
谢谢!
答案 0 :(得分:4)
对于Addon-SDK v1.0b3的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;
});
}
});