How to track outgoing requests and their response of a website with a Tampermonkey script? How to track outgoing requests and their response of a website with a Tampermonkey script? google-chrome google-chrome

How to track outgoing requests and their response of a website with a Tampermonkey script?


Yes, you certainly can, but you do not need TamperMonkey. Most browsers that allow you to develop extensions for them allow you to observe and analyze traffic.

In the case of chrome, you need to use webRequest:

https://developer.chrome.com/extensions/webRequest

The above webpage provides instructions on permissions required, and how to use the api.

For example:

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