gpt4 book ai didi

javascript - 如何使用 Tampermonkey 脚本跟踪网站的传出请求及其响应?

转载 作者:行者123 更新时间:2023-12-01 15:18:13 27 4
gpt4 key购买 nike

我想开发一个 Tampermonkey 脚本,它的作用类似于 Wireshark(嗅探传出请求及其响应),但在 Chrome(或其他浏览器)的当前选项卡中。
首先,这可能吗?如果是这样,你知道我可以用什么作为起点吗?
如果不是,是否有其他解决方案来实现这一目标(更底层)?

最佳答案

是的,您当然可以,但您不需要 TamperMonkey。大多数允许您为其开发扩展的浏览器都允许您观察和分析流量。
在 chrome 的情况下,你需要使用 webRequest:

https://developer.chrome.com/extensions/webRequest
上述网页提供了有关所需权限以及如何使用 api 的说明。
例如:

To register an event listener for a web request, you use a variationon the usual addListener() function. In addition to specifying acallback function, you have to specify a filter argument and you mayspecify an optional extra info argument.

The three arguments to the web request API's addListener() have thefollowing definitions:

var callback = function(details) {...};
var filter = {...};
var opt_extraInfoSpec = [...];
chrome.webRequest.onBeforeRequest.addListener(
callback, filter, opt_extraInfoSpec);

关于javascript - 如何使用 Tampermonkey 脚本跟踪网站的传出请求及其响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63319171/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com