Skip to content

Instantly share code, notes, and snippets.

@LuxXx
Created March 13, 2024 16:26
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 LuxXx/d9534122fe7c1275a1e90e129104777b to your computer and use it in GitHub Desktop.
Save LuxXx/d9534122fe7c1275a1e90e129104777b to your computer and use it in GitHub Desktop.
detour XMLHttpRequest
(function () {
// Preserve the original 'open' function
var originalOpen = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function () {
arguments[1] = arguments[1].replace(
"https://example.com/",
"https://detour.com/"
);
console.log("XHR intercepted:", arguments);
// Call the original 'open'
return originalOpen.apply(this, arguments);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment