Update analyze.js

This commit is contained in:
David Westgate 2013-03-15 10:31:13 -03:00
parent 0192da9a34
commit 7b6a22a878

View File

@ -1,119 +1,239 @@
function analyze() { function analyze() {
var all = document.getElementsByTagName("*"); var all = document.getElementsByTagName("*");
for (var i = 0; i < all.length; ++i) { for (var i = 0; i < all.length; ++i) {
var info = new Array(); var info = new Array();
var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT", "LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA"]; var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT", "LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA"];
if (validtags.indexOf(all[i].tagName) < 0) continue; if (validtags.indexOf(all[i].tagName) < 0) continue;
info[0] = all[i].tagName; info[0] = all[i].tagName;
switch(info[0]) { switch(info[0]) {
case "INPUT": case "INPUT":
info[1] = all[i].getAttribute("type"); info[1] = all[i].getAttribute("type");
break; break;
case "A": case "A":
info[1] = all[i].getAttribute("href"); info[1] = all[i].getAttribute("href");
break; break;
case "BUTTON" case "BUTTON":
info[1] = all[i].getAttribute("name"); info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("type"); info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("value"); info[3] = all[i].getAttribute("value");
info[4] = all[i].getAttribute("form"); info[4] = all[i].getAttribute("form");
break; break;
case "FORM": case "FORM":
info[1] = all[i].getAttribute("name"); info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("length"); info[2] = all[i].getAttribute("length");
info[3] = all[i].getAttribute("target"); info[3] = all[i].getAttribute("target");
info[4] = all[i].getAttribute("action"); info[4] = all[i].getAttribute("action");
break; break;
case "IMG": case "IMG":
info[1] = all[i].getAttribute("name"); info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("src"); info[2] = all[i].getAttribute("src");
info[3] = all[i].getAttribute("align"); info[3] = all[i].getAttribute("align");
break; break;
case "INPUT": case "INPUT":
info[1] = all[i].getAttribute("name"); info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("type"); info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("value"); info[3] = all[i].getAttribute("value");
break; break;
case "LINK" case "LINK":
info[1] = all[i].getAttribute("href"); info[1] = all[i].getAttribute("href");
info[2] = all[i].getAttribute("type"); info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("charset"); info[3] = all[i].getAttribute("charset");
break; break;
case "OPTION": case "OPTION":
info[1] = all[i].getAttribute("text"); info[1] = all[i].getAttribute("text");
info[2] = all[i].getAttribute("value"); info[2] = all[i].getAttribute("value");
info[3] = all[i].getAttribute("index"); info[3] = all[i].getAttribute("index");
break; break;
case "SELECT": case "SELECT":
info[1] = all[i].getAttribute("type"); info[1] = all[i].getAttribute("type");
info[2] = all[i].getAttribute("name"); info[2] = all[i].getAttribute("name");
info[3] = all[i].getAttribute("size"); info[3] = all[i].getAttribute("size");
break; break;
case "TABLE": case "TABLE":
info[1] = all[i].getAttribute("summmary"); info[1] = all[i].getAttribute("summmary");
info[2] = all[i].getAttribute("caption"); info[2] = all[i].getAttribute("caption");
break; break;
case "TEXTAREA": case "TEXTAREA":
info[1] = all[i].getAttribute("name"); info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("type"); info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("value"); info[3] = all[i].getAttribute("value");
break; break;
} }
generatescript(info); generatescript(info);
} }
} }
function generatescript(info) { function generatescript(info) {
var command; var command;
switch(info[0]) { switch(info[0]) {
case "A": case "A":
command = "window.location.href = '" + info[1] + "';"; command = "window.location.href = '" + info[1] + "';"
break; break;
case "BUTTON" case "BUTTON":
command = "window.location.name = '" + info[1] + "';"; command = "button.name = '" + info[1] + "';"
command = "window.location.type = '" + info[2] + "';"; + "button.type = '" + info[2] + "';"
command = "window.location.value = '" + info[3] + "';"; + "button.value = '" + info[3] + "';"
command = "window.location.form = '" + info[4] + "';"; + "button.form = '" + info[4] + "';";
break; break;
case "FORM": case "FORM":
command = "window.location.name = '" + info[1] + "';"; command = "form.name = '" + info[1] + "';"
command = "window.location.length = '" + info[2] + "';"; + "form.length = '" + info[2] + "';"
command = "window.location.target = '" + info[3] + "';"; + "form.target = '" + info[3] + "';"
command = "window.location.action = '" + info[4] + "';"; + "form.action = '" + info[4] + "';";
break; break;
case "IMG": case "IMG":
command = "window.location.name = '" + info[1] + "';"; command = "img.name = '" + info[1] + "';"
command = "window.location.src = '" + info[2] + "';"; + "img.src = '" + info[2] + "';"
command = "window.location.align = '" + info[3] + "';"; + "img.align = '" + info[3] + "';";
break; break;
case "INPUT": case "INPUT":
command = "window.location.name = '" + info[1] + "';"; command = "input.name = '" + info[1] + "';"
command = "window.location.type = '" + info[2] + "';"; + "input.type = '" + info[2] + "';"
command = "window.location.value = '" + info[3] + "';"; + "input.value = '" + info[3] + "';";
break; break;
case "LINK" case "LINK":
command = "window.location.href = '" + info[1] + "';"; command = "link.href = '" + info[1] + "';"
command = "window.location.type = '" + info[2] + "';"; + "link.type = '" + info[2] + "';"
command = "window.location.charset = '" + info[3] + "';"; + "link.charset = '" + info[3] + "';";
break; break;
case "OPTION": case "OPTION":
command = "window.location.text = '" + info[1] + "';"; command = "option.text = '" + info[1] + "';"
command = "window.location.value = '" + info[2] + "';"; + "option.value = '" + info[2] + "';"
command = "window.location.index = '" + info[3] + "';"; + "option.index = '" + info[3] + "';";
break; break;
case "SELECT": case "SELECT":
command = "window.location.type = '" + info[1] + "';"; command = "select.type = '" + info[1] + "';"
command = "window.location.name = '" + info[2] + "';"; + "select.name = '" + info[2] + "';"
command = "window.location.size = '" + info[3] + "';"; + "select.size = '" + info[3] + "';";
break; break;
case "TABLE": case "TABLE":
command = "window.location.summary = '" + info[1] + "';"; command = "table.summary = '" + info[1] + "';"
command = "window.location.caption = '" + info[2] + "';"; + "table.caption = '" + info[2] + "';";
break; break;
case "TEXTAREA": case "TEXTAREA":
command = "window.location.name = '" + info[1] + "';"; command = "window.location.name = '" + info[1] + "';"
command = "window.location.type = '" + info[2] + "';"; + "table.type = '" + info[2] + "';"
command = "window.location.value = '" + info[3] + "';"; + "table.value = '" + info[3] + "';";
break; break;
} }
alert(command); alert(command);
}function analyze() {
var all = document.getElementsByTagName("*");
for (var i = 0; i < all.length; ++i) {
var info = new Array();
var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT", "LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA"];
if (validtags.indexOf(all[i].tagName) < 0) continue;
info[0] = all[i].tagName;
switch(info[0]) {
case "INPUT":
info[1] = all[i].getAttribute("type");
break;
case "A":
info[1] = all[i].getAttribute("href");
break;
case "BUTTON":
info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("value");
info[4] = all[i].getAttribute("form");
break;
case "FORM":
info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("length");
info[3] = all[i].getAttribute("target");
info[4] = all[i].getAttribute("action");
break;
case "IMG":
info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("src");
info[3] = all[i].getAttribute("align");
break;
case "INPUT":
info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("value");
break;
case "LINK":
info[1] = all[i].getAttribute("href");
info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("charset");
break;
case "OPTION":
info[1] = all[i].getAttribute("text");
info[2] = all[i].getAttribute("value");
info[3] = all[i].getAttribute("index");
break;
case "SELECT":
info[1] = all[i].getAttribute("type");
info[2] = all[i].getAttribute("name");
info[3] = all[i].getAttribute("size");
break;
case "TABLE":
info[1] = all[i].getAttribute("summmary");
info[2] = all[i].getAttribute("caption");
break;
case "TEXTAREA":
info[1] = all[i].getAttribute("name");
info[2] = all[i].getAttribute("type");
info[3] = all[i].getAttribute("value");
break;
}
generatescript(info);
}
}
function generatescript(info) {
var command;
switch(info[0]) {
case "A":
command = "window.location.href = '" + info[1] + "';"
break;
case "BUTTON":
command = "button.name = '" + info[1] + "';"
+ "button.type = '" + info[2] + "';"
+ "button.value = '" + info[3] + "';"
+ "button.form = '" + info[4] + "';";
break;
case "FORM":
command = "form.name = '" + info[1] + "';"
+ "form.length = '" + info[2] + "';"
+ "form.target = '" + info[3] + "';"
+ "form.action = '" + info[4] + "';";
break;
case "IMG":
command = "img.name = '" + info[1] + "';"
+ "img.src = '" + info[2] + "';"
+ "img.align = '" + info[3] + "';";
break;
case "INPUT":
command = "input.name = '" + info[1] + "';"
+ "input.type = '" + info[2] + "';"
+ "input.value = '" + info[3] + "';";
break;
case "LINK":
command = "link.href = '" + info[1] + "';"
+ "link.type = '" + info[2] + "';"
+ "link.charset = '" + info[3] + "';";
break;
case "OPTION":
command = "option.text = '" + info[1] + "';"
+ "option.value = '" + info[2] + "';"
+ "option.index = '" + info[3] + "';";
break;
case "SELECT":
command = "select.type = '" + info[1] + "';"
+ "select.name = '" + info[2] + "';"
+ "select.size = '" + info[3] + "';";
break;
case "TABLE":
command = "table.summary = '" + info[1] + "';"
+ "table.caption = '" + info[2] + "';";
break;
case "TEXTAREA":
command = "window.location.name = '" + info[1] + "';"
+ "table.type = '" + info[2] + "';"
+ "table.value = '" + info[3] + "';";
break;
}
alert(command);
} }