0

So I’m trying to intercept XHR, this is the code I’ve got:

let oldXHROpen = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
 console.log("Method: " + method);
 console.log("URL: " + url);

 return oldXHROpen.apply(this, arguments);
}

It works perfectly when I run it through chrome’s console tab but doesn’t work at all when I’m running it through an extension, from what I understand it can't work though an extension for some reasons.

My question is: I'm new to JS and I have no idea how to run this code, how can I run it on every open tab or if it's not possible how can I run this code?

Thanks :)

Idanq
  • 39
  • 1
  • 6

0 Answers0