Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript chrome webRequest抛出错误_Javascript_Google Chrome - Fatal编程技术网

Javascript chrome webRequest抛出错误

Javascript chrome webRequest抛出错误,javascript,google-chrome,Javascript,Google Chrome,我正在编写能够记录所有HTTP请求的chrome扩展,就像控制台窗口中的“网络中的请求”选项卡一样 清单文件如下所示 { "manifest_version": 2, "name": "Youtube Controls", "description": "This extension demonstrates a browser action with kittens.", "version": "1.0", "permissions": [

我正在编写能够记录所有HTTP请求的chrome扩展,就像控制台窗口中的“网络中的请求”选项卡一样

清单文件如下所示

{
    "manifest_version": 2,

    "name": "Youtube Controls",
    "description": "This extension demonstrates a browser action with kittens.",
    "version": "1.0",

    "permissions": [
        "webRequest",
        "webRequestBlocking",
        "<all_urls>"
    ],
    "content_scripts":[{
        "matches": ["https://www.youtube.com/*"],
        "js":["youtube.js"]
    }],
    "background":{
        "scripts": ["wb.js"]
    },
    "browser_action": {
        "default_icon": "youtube.png",
        "default_popup": "popup.html"
    }
}
wb.js(后台脚本)

有什么问题?如何修复它

chrome.extension.onRequest.addListener(function(request, sender, sendResponse){
    chrome.runtime.sendMessage({
        greeting: 'hello'
    });
});
chrome.runtime.onMessage.addListener(function(request, sender, response){
    console.log(request);
    chrome.webRequest.onCompleted.addListener(function(details){
        console.log(details);
    },{
        urls: ["<all_urls>"]
    });
});
Error in event handler for (unknown): Cannot read property 'error' of undefined
Stack trace: TypeError: Cannot read property 'error' of undefined
    at chrome-extension://ammnjfgoofnjeoglmbhbeijmmnmfjbdk/popup.js:13:30
    at disconnectListener (extensions::messaging:335:9)
    at EventImpl.dispatchToListener (extensions::event_bindings:397:22)
    at Event.publicClass.(anonymous function) [as dispatchToListener] (extensions::utils:93:26)
    at EventImpl.dispatch_ (extensions::event_bindings:379:35)
    at EventImpl.dispatch (extensions::event_bindings:403:17)
    at Event.publicClass.(anonymous function) [as dispatch] (extensions::utils:93:26)
    at dispatchOnDisconnect (extensions::messaging:290:27) extensions::uncaught_exception_handler:9