Created
January 25, 2018 07:14
-
-
Save jderusse/f1be5426cdfac7dad9967e962a2a3160 to your computer and use it in GitHub Desktop.
Async document.writeln
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
const evalCode = (code) => { | |
const oldWrite = document.writeln; | |
const sandbox = document.createElement('div'); | |
document.body.appendChild(sandbox); | |
document.writeln = (content) => { | |
sandbox.innerHTML += content; | |
}; | |
try { | |
(window.execScript || function(data) { | |
window['eval'].call(window, data); | |
})(code); | |
} finally { | |
document.writeln = oldWrite; | |
document.body.removeChild(sandbox); | |
} | |
return sandbox.innerHTML; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment