douyan8027 2015-02-20 01:57
浏览 87

拒绝加载Chrome扩展程序脚本

I am trying to make a call to this site and receive a json object back. How can I interface with this API properly within my chrome extension given CSP?

Error: Refused to load the script 'http://thesaurus.altervista.org/service.php?word=smile&language=en_US&output=json&key=REMOVEDMYKEY&callback=thesaurus' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".

var word = "smile";
var s = document.createElement("script");
s.src = "http://thesaurus.altervista.org/service.php?word="+ word +"&language=en_US&output=json&key=REMOVEDMYKEY&callback=thesaurus";
document.getElementsByTagName("head")[0].appendChild(s);
function thesaurus(result) { 
  output = "";
  for (key in result.response) { 
list = result.response[key].list; 
output += list.synonyms+"<br>"; 
} 
if (output) 
document.getElementById("synonyms").innerHTML = output; 
}
  • 写回答

2条回答 默认 最新

  • duanchi6377 2015-02-20 18:29
    关注

    Please check that your script is declaring required permissions, as described here: https://developer.chrome.com/extensions/xhr#requesting-permission
    https://developer.chrome.com/apps/app_external#external

    Inside your manifest there should be something like:

    "permissions": [
      "*http://thesaurus.altervista.org/*"
    ],
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器