Is it possible to catch requests from another exte

2019-08-21 16:48发布

In my extension I use chrome.webRequest to catch requests from any web pages and it works like a charm.
But I can not catch any requests initialized from another extension. My manifest:

"permissions": [
    "tabs",
    "webRequest",
    "webRequestBlocking",
    "<all_urls>"
  ], 

background.js:

chrome.webRequest.onBeforeRequest.addListener(function (data) {
  console.log('catched', data);
}, {urls: ['<all_urls>']});

Tests:

  1. open tab with http://google.com:
    catched https://www.google.com/

  2. open extension console and run fetch('http://google.com'):
    catched http://google.com/

  3. open another extension console and run fetch('http://google.com'):
    // no output

Does anybody know if is it possible and if so, how to set it up? Thanks!

1条回答
你好瞎i
2楼-- · 2019-08-21 17:27

Updated

My previous answer it not correct, see @Rob W's comments.

But when @Xan mentioned that extension URLs were visible to other extensions, it became apparent that this behavior is undesirable and a security issue, so I removed the ability for extensions to see other extensions' requests

Previous answer

It's not allowed to handle requests sent from other extensions.

In addition, even certain requests with URLs using one of the above schemes are hidden, e.g., chrome-extension://other_extension_id where other_extension_id is not the ID of the extension to handle the request, https://www.google.com/chrome, and others (this list is not complete).

查看更多
登录 后发表回答