Last active
August 29, 2015 14:27
-
-
Save hackvertor/c2fec87e60a0a5b751a7 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 SOMEGuard(callbackStr) { | |
var o = [], flag = true, i, callbackObj; | |
callbackStr = callbackStr.replace(/[^\w.]/gi,'').split('.'); | |
for(i=0;i<callbackStr.length;i++) { | |
o.push(callbackStr[i]); | |
try { | |
callbackObj = Function("return window."+o.join('.'))(); | |
if(callbackObj === window.opener) { | |
flag = false; | |
break; | |
} | |
if(window.HTMLElement) { | |
if(callbackObj instanceof HTMLElement) { | |
flag = false; | |
break; | |
} | |
} | |
if(window.Node) { | |
if(callbackObj instanceof Node) { | |
flag = false; | |
break; | |
} | |
} | |
if(typeof callbackObj === 'object' && typeof callbackObj.nodeType === 'number' && typeof callbackObj.nodeName === 'string') { | |
flag = false; | |
break; | |
} | |
if(callbackStr[i] === 'returnValue') { | |
flag = false; | |
break; | |
} | |
} catch(e){ | |
flag = false; | |
} | |
} | |
return flag; | |
} |
Author
hackvertor
commented
Aug 22, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment