Javascript chrome.tabs.create是否工作不正常?
在舱单中:Javascript chrome.tabs.create是否工作不正常?,javascript,html,google-chrome,manifest,Javascript,Html,Google Chrome,Manifest,在舱单中: { "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:
{
"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”
chrome.tabs.create({url:(“http://www.google.com/")});
为什么它不打开www.google.com的主页?扩展的其余部分可以工作,但只有“chrome.tabs.create”部分不能工作。我的分机确实有tab权限,我看不出有什么问题
编辑
拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script src'self'chrome extension resource:”
我只是看到了那个错误,不管怎样为了防止那个^^^^ 不允许Chrome扩展获取不在扩展内或列为资源的脚本(正如错误声明中有点令人困惑地指出的那样)。您可以定义CSP(内容安全策略)来更改此行为。默认设置如下所示: “内容安全策略”:“脚本src'self'chrome扩展资源:;对象src'self' 你可能想要这样的东西: “内容安全策略”:“脚本src'self'chrome扩展资源:;对象src'self' 将该行粘贴到manifest.json:-) 可以找到更多的例子
<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>