Created
February 8, 2013 21:10
-
-
Save terinjokes/4741938 to your computer and use it in GitHub Desktop.
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
function globalEval(text) { | |
/** | |
* Modified version of runScriptText() from FuseJS | |
* Copyright (c) 2008-2010 John-David Dalton, https://github.com/jdalton/fusejs | |
* | |
* FuseJS is distributed under an MIT license. <https://github.com/jdalton/fusejs> | |
*/ | |
var suid = _.uniqueId('fused_'), | |
script, | |
result, | |
head; | |
if (text && text !== '') { | |
CloudFlare[suid] = {'text': String(text)}; | |
head = document.getElementsByTagName('head')[0]; | |
text = 'CloudFlare.' + suid + '.returned=eval(' + | |
'CloudFlare.' + suid + '.text);'; | |
text = 'if("arguments" in this){' + text + | |
'}else{arguments=void 0;' + text + | |
'delete arguments}'; | |
script = document.createElement('script'); | |
script.async = true; | |
(script.firstChild || script.appendChild(script.ownerDocument.createTextNode(''))).data = text === null ? '' : text; | |
head.insertBefore(script, head.firstChild); | |
head.removeChild(script); | |
result = CloudFlare[suid].returned; | |
delete CloudFlare[suid]; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment