Created
July 29, 2020 21:11
-
-
Save fabrizim/fc4a67c72f5506ee79f895836fd44ef2 to your computer and use it in GitHub Desktop.
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
function stripScript( html ){ | |
let match; | |
const re = /<script[^>]+?src=['"](.+?)['"][^>]*?><\/script>/gi; | |
while( (match =re.exec(html)) ){ | |
const script = document.createElement('script'); | |
script.src = match[1]; | |
document.body.appendChild( script ); | |
} | |
html = html.replace(re, ''); | |
return html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment