Created
September 21, 2020 19:47
-
-
Save round/d1d1552cd978a0850e38ab77def4eece to your computer and use it in GitHub Desktop.
Self unwrapping <script> tag
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
<script> | |
var thisScript = document.scripts[document.scripts.length - 1]; | |
var parent = thisScript.parentElement; | |
const wrapper = document.createElement('div'); | |
wrapper.innerHTML = 'Output'; | |
parent.replaceChild(wrapper.firstChild, thisScript); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment