【发布时间】:2018-12-29 19:46:35
【问题描述】:
我在这里遇到了一些严重的问题,我尝试为 gmail 构建一个 chrome 扩展,但我的界面或内容脚本都没有加载,每当我检查弹出控制台时都会看到这个错误。
Unchecked runtime.lastError while running tabs.executeScript:
This page cannot be scripted due to an ExtensionsSettings policy.
at Object.callback (chrome-extension://hchilaodbnedmljenkfdfpjmgmlkmpci/js/popup.js:247:17)
错误与我的 JSON 文件有关吗?
我声明内容脚本如下
{
"name": "name",
"version": "1.0",
"description": "description",
"permissions": [
"activeTab",
"tabs",
"*://mail.google.com/*",
"declarativeContent",
"storage",
"contentSettings"
],
"background": {
"scripts": ["js/send.js"],
"persistent": false
},
"browser_action": {
"default_popup": "index.html",
"default_icon": {
"16": "images/imagege1.png",
}
},
"icons": {
"16": "images/image1.png",
},
"web_accessible_resources": [
"css/bootstrap.min.css",
"js/jquery-3.3.1.slim.min.js",
"js/popper.min.js",
"js/bootstrap.min.js"
],
"content_scripts": [{
"matches": [
"*://mail.google.co.in/*",
],
"css": [
"css/bootstrap.min.css"
],
"js": [
"js/jquery-3.3.1.slim.min.js",
"js/bootstrap.js",
"js/send.js",
"js/bootstrap.min.js"
],
"run_at": "document_end",
"all_frames": true
}],
"manifest_version": 2
}
这里有一段 JS 代码,以防万一有人需要它
【问题讨论】:
-
格式化了sn-p,去掉了它周围的
<pre></pre>。 -
您的问题应该显示调用 executeScript 的相关代码。
-
相同的代码可以在很多其他网站上运行,为什么不是这个?这段代码非常标准......我的观点是内容脚本,因为它知道根本没有在 Gmail 上执行
标签: javascript google-chrome google-chrome-extension google-chrome-devtools chromium