“No matching signature” error on adding a chrome.webRequest listener

点点圈 提交于 2020-05-08 09:36:07

问题


I have this code:

chrome.webRequest.onCompleted.addListener(function(details){
  console.log(details);
});

I'm trying to understand and use the chrome.webRequest API. I can't figure why the code isn't working, I just wanna give a try to the API by logging all the requests made by chrome. I've set the permissions in my manifest on these two patterns http://*/* and https://*/* but i will always get this error from my background script: Uncaught TypeError: No matching signature. Any help is appreciated.


回答1:


"No matching signature" means you're passing the wrong parameters. As you can see in the documentation's concepts and examples you need to specify at least two parameters. The documentation for individual methods doesn't mention that which is really confusing, and you can report it on https://crbug.com.

chrome.webRequest.onCompleted.addListener(
  function(details) {
    console.log(details);
  },
  {urls: ["<all_urls>"]}
);

To view the background script's console see this answer.



来源:https://stackoverflow.com/questions/57745530/no-matching-signature-error-on-adding-a-chrome-webrequest-listener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!