如何将自己的脚本加载到Firefox扩展的选项卡中?

时间:2018-06-19 12:48:04

标签: javascript firefox firefox-webextensions

我正在尝试更改Firefox扩展标签(moz-extension:// URL之一)的行为。我试图将以下内容粘贴到开发控制台中:

const script =
    document.querySelector("script#updater_script")
    ||
    document.createElement("script");
script.src = "http://127.0.0.1:1337/tampermonkey_plugin.js";
script.type = "module";
script.id = "updater_script";

if(script.parentNode == null)
    document.body.appendChild(script);

但是我得到一个错误:

  

内容安全政策:该页面的设置阻止了http://127.0.0.1:1337/tampermonkey_plugin.js(“ script-src”)资源的加载。

如何避免此安全错误?在这种情况下,我可以告诉Firefox信任localhost吗?还是localhost服务器可以发送允许加载脚本的标头?

0 个答案:

没有答案
相关问题