Skip to content

Instantly share code, notes, and snippets.

View DexterHaslem's full-sized avatar
💭
why are you taking advice from a site that goes down weekly?

Dexter M Haslem DexterHaslem

💭
why are you taking advice from a site that goes down weekly?
View GitHub Profile
@DexterHaslem
DexterHaslem / intercept-xhr.js
Created June 7, 2022 04:30
Intercept XHR requests so that we can do something useful with it.
// Taken from https://stackoverflow.com/a/27363569
// Allows for the object to be interrogated
((() => {
const origOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
console.log('request started!');
this.addEventListener('load', function() {
console.log('request completed!');
console.log(this.readyState); //will always be 4 (ajax is completed successfully)