Reputation: 1
Essentially, I'm creating a Chrome extension that needs to read a request being sent by the website to one of their internal servers and returns a JSON object which I would like my extension to be able to read.
I've wanted to use something I've found (probably here, I've done so much research I kinda forget). This would allow me to see any XMLHttpRequest.open calls, however it appears within the extension it's using a local XMLHttpRequest.
XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open;
var myOpen = function(method, url, async, user, password) {
this.onreadystatechange = function()
{
if (this.readyState == 4)
alert(this.responseText);
}
//call original
this.realOpen (method, url, async, user, password);
}
//ensure all XMLHttpRequests use our custom open method
XMLHttpRequest.prototype.open = myOpen;
What I want is to use this xhr to trigger my extension into action, anyone have any idea how I can do this?
Upvotes: 0
Views: 1206