Skip to content

Instantly share code, notes, and snippets.

@A1rPun
Last active August 17, 2017 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A1rPun/bbefbeb451ec118cd8af5568265f6dcf to your computer and use it in GitHub Desktop.
Save A1rPun/bbefbeb451ec118cd8af5568265f6dcf to your computer and use it in GitHub Desktop.
Get duplicate requests in JavaScript
// deburglar.getDupes();
var deburglar = (function () {
var dict = {};
var maybeTheOriginalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function (method, url) {
if (!dict[url])
dict[url] = 0;
dict[url]++;
return maybeTheOriginalOpen.apply(this, arguments);
};
return {
getDupes: function () {
return dict;
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment