Created
April 11, 2012 16:51
-
-
Save jbclements/2360489 to your computer and use it in GitHub Desktop.
Fritch
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
<html> | |
<head> | |
<script type="text/javascript"> | |
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); | |
Components.utils.import("resource://gre/modules/reflect.jsm"); | |
var varrefs = []; //holds our varref list | |
//try and open source file and parse it | |
function srcParser( ) | |
{ | |
var src = document.getElementById('sourceBox').value; | |
try | |
{ | |
var sourceNode = Reflect.parse(src); | |
walk(sourceNode); | |
document.write("<p><b><center>"); | |
for(var key in varrefs) | |
{ | |
document.write(varrefs[key] + ", "); | |
} | |
document.write("</p></b></center>"); | |
alert("Sick Tight"); | |
} | |
catch(err) | |
{ | |
alert("No good bush wack'n barracuda!"); | |
} | |
} | |
//Recursive function to walk source code tree | |
var walk = function(o) | |
{ | |
for(var prop in o) | |
{ | |
if(o.hasOwnProperty(prop)) | |
{ | |
var val = o[prop]; | |
if(typeof val == 'object') | |
{ | |
if(val != null) | |
{ | |
if(val.type === "VariableDeclaration") | |
{ | |
varrefs.push(val.property);//declarations[0].id.properties.key); | |
} | |
} | |
walk(val); | |
} | |
} | |
} | |
}; | |
</script> | |
</head> | |
<body> | |
<center><p>Enter Some JavaScript, get in your Van, and hit the gas pedal.</p></center> | |
<center><input type="button" onclick="srcParser( )" value="Vrooooooomm!" /></center> | |
<form name="frm"> | |
<textarea id="sourceBox" rows="100" cols="100" value="" ></textarea> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment