Skip to content

Instantly share code, notes, and snippets.

@flashlin
Created February 27, 2021 00:35
Show Gist options
  • Save flashlin/610dad72b2e1017f69032aa6b22b0ff7 to your computer and use it in GitHub Desktop.
Save flashlin/610dad72b2e1017f69032aa6b22b0ff7 to your computer and use it in GitHub Desktop.
xhook ajax
document.onreadystatechange = function () {
console.log("test", document.readyState);
if (document.readyState === "interactive") {
var modif2 = document.createElement("script");
modif2.type = "text/javascript";
modif2.src = "https://unpkg.com/xhook@1.4.9/dist/xhook.min.js";
document.getElementsByTagName("head")[0].appendChild(modif2);
console.log("--- inserted src ----");
} else if (document.readyState === "complete") {
console.log("test2");
var modif = document.createElement("script");
modif.type = "text/javascript";
modif.innerHTML = `
xhook.after(function(request, response) {
console.log(request.url);
console.log(request.method);
console.log(request.body);
console.log('-----request accepted -----');
console.log(response.text);
});
`;
document.getElementsByTagName("head")[0].appendChild(modif);
console.log("--- injected JAVASCRIPT ----");
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment