I'm currently writing a chrome extension and require to monitor and get a header from a http POST
request from a site. How would I wait for a request from the site and then save the specified header's argument to a variable for future use?
Asked
Active
Viewed 355 times
1

Soupy
- 160
- 10
-
In a content script you can [intercept XMLHttpRequest](https://stackoverflow.com/a/6218998/). In the background script you can use chrome.webRequest.onHeadersReceived event. – wOxxOm Oct 05 '20 at 07:03
1 Answers
0
I ended up using:
chrome.webRequest.onSendHeaders.addListener(function (details) {
//my stuff here
}, {
urls: ["<all_urls>"],
types: ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"]
}, ["requestHeaders"]);
along with some code to store the varible i got from details.*
.

Soupy
- 160
- 10