Last active
August 17, 2017 09:50
-
-
Save A1rPun/bbefbeb451ec118cd8af5568265f6dcf to your computer and use it in GitHub Desktop.
Get duplicate requests in JavaScript
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
// 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