0

I'm making a chrome plugin which will intercept an AJAX response and modify it before it is displayed.

I found this piece of code:

(function(open) {
  XMLHttpRequest.prototype.open = function() {
    alert('Intercept');
    open.apply(this, arguments);
  };
})(XMLHttpRequest.prototype.open);

from this question: Intercept Ajax request?

I'm not sure how to make use of it. For example I read another question talking about using an addEventListener, I'm not sure what that would look like. I'm quite lost on this and would appreciate any guidance.

Community
  • 1
  • 1
Sentinel
  • 441
  • 1
  • 6
  • 25
  • 1
    there are better techniques in chrome extension - e.g. https://developer.chrome.com/extensions/webRequest – Jaromanda X May 16 '17 at 06:40
  • Don't think it's possible to modify the body of the request using web request: http://stackoverflow.com/questions/18310484/chrome-extension-modifying-http-response This would be great if I wanted to do something like a redirect but the ajax response displays a table and I just need to modify some contents in the table before they're displayed. – Sentinel May 16 '17 at 07:11

0 Answers0