是否可以捕获来自其他扩展程序的请求? [英] Is it possible to catch requests from another extension?

查看:95
本文介绍了是否可以捕获来自其他扩展程序的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的扩展程序中,我使用 chrome.webRequest 捕获来自任何网页的请求,它的工作原理就像一个超级按钮.
但是我无法捕获从另一个扩展初始化的任何请求.我的清单:

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:

background.js:

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

测试:

  1. 带有 http://google.com 的打开标签:
    捕获了https://www.google.com/

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

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

打开另一个扩展程序控制台,然后运行 fetch('http://google.com'):
//无输出

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!

推荐答案

已更新

我以前的回答不正确,请参阅@Rob W的评论.

Updated

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

但是,当 @Xan提到扩展URL是对于其他扩展名可见,很明显和一个安全问题,因此我删除了扩展程序查看其他扩展程序请求的功能

上一个答案

不允许处理其他扩展发送的请求.

此外,即使使用上述方案之一的某些带有URL的请求也被隐藏,例如, chrome-extension://other_extension_id,其中other_extension_id不是用于处理该请求的扩展程序的ID https://www.google.com/chrome 以及其他(此列表不完整).

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).

这篇关于是否可以捕获来自其他扩展程序的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆