Skip to content

Instantly share code, notes, and snippets.

@jojijacobk
Created August 10, 2019 16:18
Show Gist options
  • Save jojijacobk/73577fc814eb6030a1d909777a54db9b to your computer and use it in GitHub Desktop.
Save jojijacobk/73577fc814eb6030a1d909777a54db9b to your computer and use it in GitHub Desktop.
Intercept any XMLHttpRequests happening in your page either by your own code or from a third party library
(function(originalOpen) {
XMLHttpRequest.prototype.open = function() {
this.addEventListener('progress', function() {
console.log('request in progress);
});
this.addEventListener('load', function() {
console.log('request complete);
});
originalOpen.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment