I'm trying to intercept POST request made by the website and intercept the response but somehow I am not getting the correct result.
I'm trying this same on Facebook ads library and trying to fetch the response body, I can see the POST request made by checking the "Network tab" in the browser. I want to fetch those responses within the code and then save it for later use.
chrome.webRequest.onBeforeRequest.addListener(
function (details) {
if (details.method == "POST")
// Use this to decode the body of your post
var postedString = decodeURIComponent(
String.fromCharCode.apply(
null,
new Uint8Array(details.requestBody.raw[0].bytes)
)
);
console.log(postedString);
},
{ urls: ["<all_urls>"] },
["requestBody"]
);
That's what I have written/checked from stackoverflow so far.