0

I want to write some javascript AJAX and Websocket hooking code in Chrome Extension.

Code is like below.

(function() {
        console.log("ajax hooking init");
    var origOpen = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function() {
        ...  
    }
}

But, though above code do work, but it didn't hook any requests in current page. Do i something wrong? How to do hook some requests via chrome extension??

GMB
  • 216,147
  • 25
  • 84
  • 135
sSunFlowers
  • 155
  • 12
  • 1
    Since the content script runs in isolated world, you need to [put the hook in a script element](https://stackoverflow.com/a/9517879). – wOxxOm Dec 13 '18 at 14:12
  • Looking at the advice _after_ the code in [this answer](https://stackoverflow.com/a/31182643/934239) will help. – Xan Dec 13 '18 at 14:34

0 Answers0