I am trying to get the formData
of a POST
request with a chrome extension. I am using the following manifest.json
file and background.js
file. However, when I console.log the requestBody I cannot see the formData which was sent by the website. How can I get the form elements?
manifest.json
{
"manifest_version": 2,
"name": "Form Data",
"description": "Looks at some form data.",
"version": "0.9",
"background": {
"scripts": ["background.js"]
},
"permissions": [
"webRequest",
"webRequestBlocking",
"<all_urls>"
]
}
background.js
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if(details.method == "POST")
console.log(JSON.stringify(details));
},
{urls: ["<all_urls>"]},
["requestBody"]
);
Example Response:
{"frameId":0,"initiator":"https://example.com","method":"POST","parentFrameId":-1,"requestBody":{"raw":[{"bytes":{}}]},"requestId":"13910","tabId":430,"timeStamp":1645826234368.5469,"type":"xmlhttprequest","url":"https://www.example.com/api/v4/login"}