开发者

Use Remote Content Script File/Javascript in Page-Mod

Is there any way to easily use a remote javascript file as a content script with the page-mod API?

I am trying to build some simple addons for my own use to automate 开发者_运维技巧some repetitive stuff. Because the pages I will be modding change from time to time, and I will need to be updating the "content script" javascript accordingly, it would be nice if I only had to edit it on my server and the addon/extension would work again without editing and repacking the xpi. I'm pretty sure I would be able to hack something together that will accomplish this, but if there is any easy way to do it I'm all ears :)


The content script itself should never be a remote script, that would be a security vulnerability. But the content script can insert a remote script into the web page:

var pageMod = require("page-mod");
pageMod.PageMod({
  include: "...",
  contentScript: 'var script = document.createElement("script");'+
                 'script.src = "...";'+
                 'document.body.appendChild(script);'
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜