Created
February 27, 2021 00:35
-
-
Save flashlin/610dad72b2e1017f69032aa6b22b0ff7 to your computer and use it in GitHub Desktop.
xhook ajax
This file contains hidden or 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
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/[email protected]/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