Skip to content

Instantly share code, notes, and snippets.

@jorendorff
Last active October 7, 2023 23:20
Show Gist options
  • Save jorendorff/6fff207db165d32c1182de34430ecd04 to your computer and use it in GitHub Desktop.
Save jorendorff/6fff207db165d32c1182de34430ecd04 to your computer and use it in GitHub Desktop.
(function () {
var XHREventTargetPrototype = Object.getPrototypeOf(XMLHttpRequest.prototype);
var desc = Object.getOwnPropertyDescriptor(XHREventTargetPrototype, "onload");
var real_set_onload = desc.set;
Object.defineProperty(XHREventTargetPrototype, "onload", {
set: function onload(real_callback) {
real_set_onload.call(this, function fake_callback() {
console.log("loaded:", arguments);
return real_callback.apply(this, arguments);
});
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment