Skip to content

Instantly share code, notes, and snippets.

@mimshins
Forked from mrchess/gist:1820380
Created November 10, 2021 10:12
Show Gist options
  • Select an option

  • Save mimshins/74159c8efe7f3c5bd93dcb9eda6ac2ee to your computer and use it in GitHub Desktop.

Select an option

Save mimshins/74159c8efe7f3c5bd93dcb9eda6ac2ee to your computer and use it in GitHub Desktop.
Exposes a variable openHTTPs which keeps track of how many XMLHttpRequests you have active.
<script>
(function() {
var oldOpen = XMLHttpRequest.prototype.open;
window.openHTTPs = 0;
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
window.openHTTPs++;
this.addEventListener("readystatechange", function() {
if(this.readyState == 4) {
window.openHTTPs--;
}
}, false);
oldOpen.call(this, method, url, async, user, pass);
}
})(XMLHttpRequest);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment