I'm currently developing a Chrome extension. I only don't understand if/how I can change a response body in Chrome.
Example:
A website does an XMLhttpRequest to example.com/is_logged_in.php
. This returns 0
. I want to make a script that auto changes the 0
to an 1
. And not by changing the javascript that makes the call, but by changing the response body, so the javascript thinks it recieved a 1
.
I know you can change the response headers with chrome.webRequest but I want to change the response body, not the response headers.
It's currently possible by changing your hosts file
so example.com
'redirects' to your own hosting. Then you create is_logged_in.php
and set the content to 1
. The script then thinks the user is logged in. I have checked it, and this works. But now I want this in a Chrome extension so it is more user friendly.
Can Chrome change a response (body, not its headers) and if so, how?
According to this active chromium issue you cannot for now modify the response body in a JavaScript extension.
If you really want to do that, a possible way could be using NPAPI Plugins, but unfortunately it's not an option in my case because of the security issues.
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