【问题标题】:Is it possible to catch requests from another extension?是否可以捕获来自另一个扩展的请求?
【发布时间】:2016-06-20 15:38:34
【问题描述】:

在我的扩展程序中,我使用chrome.webRequest 来捕获来自任何网页的请求,它就像一个魅力。
但我无法捕获从另一个扩展初始化的任何请求。 我的清单:

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

background.js:

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

测试:

  1. http://google.com打开标签:
    catched https://www.google.com/

  2. 打开扩展控制台并运行fetch('http://google.com'):
    catched http://google.com/

  3. 打开另一个扩展控制台并运行fetch('http://google.com'):
    // no output

有人知道这是否可行,如果可以,如何设置? 谢谢!

【问题讨论】:

    标签: google-chrome-extension webrequest


    【解决方案1】:

    更新

    我之前的回答不正确,请参阅@Rob W 的 cmets。

    但是当@Xan mentioned that extension URLs were visible to other extensions,很明显这种行为is undesirable and a security issue, so I removed the ability for extensions to see other extensions' requests

    上一个答案

    不允许handle requests sent from other extensions

    此外,即使某些 URL 使用上述方案之一的请求也会被隐藏,例如 chrome-extension://other_extension_id 其中 other_extension_id 不是处理请求的扩展程序的 IDhttps://www.google.com/chrome 和其他人(此列表不完整)。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多