Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change response in Chrome extension

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?

like image 715
Bart Langelaan Avatar asked Nov 26 '22 09:11

Bart Langelaan


1 Answers

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.

like image 156
VAV Avatar answered Dec 20 '22 20:12

VAV