Created
October 27, 2016 19:30
-
-
Save plmrry/ac0af595d41bdb3391d1e45f895fcbb6 to your computer and use it in GitHub Desktop.
Capture XHR Requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var XHR = XMLHttpRequest.prototype; | |
var open = XHR.open; | |
var send = XHR.send; | |
XHR.open = function(method, url) { | |
requests.push(this); | |
this._method = method; | |
this._url = url; | |
return open.apply(this, arguments); | |
}; | |
XHR.send = function(data) { | |
// this.addEventListener('load', function() { | |
// /* Method */ this._method | |
// /* URL */ this._url | |
// /* Response body */ this.responseText | |
// }); | |
const that = this; | |
if (blocked.some(function(regex) { return that._url.match(regex) })) return; | |
return send.apply(this, arguments); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment