I want to write an extension for Chrome to watch my XHR calls and I found that i have to use webRequest for this.
I want to get the response-body of the request but i never can find how to do this. Is this possible?
// chrome.browserAction.onClicked.addListener(function (tab) {
var callback = function(details) {
var url = details.url;
console.log(details);
};
var filter = {
urls: ["*://safan.dev/*"]
};
var ops = ["requestBody"];
chrome.webRequest.onBeforeRequest.addListener(
callback, filter, ops
);
// });
And manifest:
{
"manifest_version": 2,
"name": "Forge of Empires",
"description": "FOE",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"webRequest",
"<all_urls>"
],
"background": {
"scripts": ["logic.js"]
}
}
To view the response body to a request: Click the URL of the request, under the Name column of the Requests table. Click the Response tab.
To use the webRequest API for a given host, an extension must have the "webRequest" API permission and the host permission for that host. To use the "blocking" feature, the extension must also have the "webRequestBlocking" API permission.
I want to get the response-body of the request but i never can find how to do this. Is this possible?
Not at the moment. There is a long-standing feature request.
Note that you can do it using devtools.network
API (requires Dev Tools to be open) or Debugger API (requires Dev Tools to be closed, low-level).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With