Last active
August 22, 2018 17:08
-
-
Save bitsmanent/154a5a42c90d67fbdec1 to your computer and use it in GitHub Desktop.
Track XMLHttpRequest (better version here: https://gist.github.com/clamiax/7325ca5c075d954dc61406d7e0cdc7aa)
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 trackxhr() { | |
var xhrsend = XMLHttpRequest.prototype.send; | |
XMLHttpRequest.prototype.send = function() { | |
var onready = this.onreadystatechange; | |
console.log('XHR', 'sending...'); | |
this.onreadystatechange = function() { | |
if(this.readyState == 4) | |
console.log('XHR', 'done'); | |
if(onready) | |
onready.apply(this, arguments); | |
}; | |
xhrsend.apply(this, arguments); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment