Last active
May 17, 2023 08:13
-
-
Save CharlyJazz/edd281193f334264eb41e809b581f749 to your computer and use it in GitHub Desktop.
XMLHttpRequest injection load javascript script.
This file contains 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
//Before </body> tag | |
<script> | |
var xhr = new XMLHttpRequest(); | |
xhr.open("get", "cookbook.js", true); | |
xhr.onreadystatechange = function () { | |
if (xhr.readyState == 4) { | |
if (xhr.status >= 200 && xhr.status < 300 || xhr.status == 304) { | |
var script = document.createElement("script"); | |
script.type = "text/javascript"; | |
script.text = xhr.responseText; | |
document.body.appendChild(script); | |
} | |
} | |
}; | |
xhr.send(null); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment