[英]chrome.tabs.create not working properly?
在清单中:
{
"manifest_version": 2,
"version": "0.1",
"name": "test",
"description": "test",
"content_scripts": [
{
"matches": ["http://www.roblox.com/*", "https://www.roblox.com/*"],
"js": ["jquery.js", "ecyInject.js"]
},
{
"matches": ["http://www.roblox.com/Economy"],
"js": ["jquery.js", "ecyPage.js"]
}
],
"permissions": [
"notifications", "tabs", "http://www.roblox.com/"
],
"background": {
"page": "main.html"
}
}
这就是“ main.html”
<html>
<head>
<script src="jquery.js"></script>
<script src="Services.js"></script>
<script>
chrome.tabs.create({url:("http://www.google.com/")});
</script>
</head>
<body>
</body>
</html>
为什么无法打开www.google.com主页? 该扩展的其余部分均有效,但是仅“ chrome.tabs.create”部分无效。 我的扩展程序确实具有制表符权限,但我看不出有什么问题。
编辑
“拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“ script-src'self'chrome-extension-resource:”。
我只是看到那个错误,无论如何要防止这种错误? ^^^^
Chrome扩展程序不允许抓取不在扩展程序中或未列为资源的脚本(因为该错误有些令人困惑地表示)。 您可以定义CSP(内容安全策略)以更改此行为。 默认值如下所示:
“ content_security_policy”:“脚本-src'自我'chrome-extension-resource:;对象-src'自我'”,
您可能想要这样的东西:
“ content_security_policy”:“脚本src'self'chrome-extension-resource: http : //www.google.com ; object-src'self'”,
将该行粘贴在manifest.json中:-)
可以在这里找到更多示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.