raz*_*113 3 javascript google-chrome google-chrome-extension
尝试编写一个非常简单的chrome 扩展,作为测试,我想添加控制台日志以进行调试。但是,我不断收到此错误
运行时未检查runtime.lastError
webRequestInternal.addEventListener:您需要在清单文件中请求主机权限,以便收到来自 webRequest API 的请求的通知。
我已经尝试添加我能找到的所有权限,但没有任何运气。有人可以帮我吗!
{
"manifest_version": 2,
"name": "test",
"description": "testing app",
"version": "1.0",
"background": {
"scripts": ["small.js"],
"persistent": true
},
"permissions": ["webRequest", "webRequestBlocking", "tabs", "background", "storage"],
"optional_permissions": ["http://*/*", "https://*/*", "<all_urls>"]
}
Run Code Online (Sandbox Code Playgroud)
chrome.webRequest.onBeforeRequest.addListener(function(details) {
if (details.method === "POST") {
alert('here');
console.log('logging here');
} else if (details.method === "GET") {
alert('there');
console.log('logging there');
}
}, {
urls: ["<all_urls>"]
}, ["blocking", "requestBody"]);
Run Code Online (Sandbox Code Playgroud)
Abr*_*rar 10
我遇到了同样的问题,有类似的错误信息。manifest.json中的一个简单更新修复了这个问题。
该permissions数组如下所示:
"permissions": [
"alarms",
"contextMenus",
"storage",
"notifications",
"webRequest",
"webRequestBlocking",
"<all_urls>"
],
Run Code Online (Sandbox Code Playgroud)
添加<all_urls>inpermissions将解决您的问题。
| 归档时间: |
|
| 查看次数: |
3384 次 |
| 最近记录: |