Command Renamer

DeletedUser

Guest
Hello, looking to get some scripts again, I've found this one

javascript:table=document.getElementById("commands_table");rows=table.getElementsByTagName("tr");var timeDiff={setStartTime:function(){d=new Date();time=d.getTime()},getDiff:function(){d=new Date();return(d.getTime()-time)}};timeDiff.setStartTime();var troopArray=["Sp","Sw","Ax","Ar","Sc","LC","Ma","HC","Ra","Ca","*NOB*"];version=1.15;nProcessed=0;nProper=0;for(i=1;i<rows.length-1;i++){cells=rows.getElementsByTagName("td");if((cells[0].innerHTML.toString().match("Support for"))||(cells[0].innerHTML.toString().match("Attack on"))){new_name='';theseTroops=new Array();totalTroops=0;for(j=3;j<cells.length;j++){troop='';troop=troopArray[j-3];if(troop!=''){if(cells[j].innerHTML!=0){new_name+=troop+":"+cells[j].innerHTML+" ";theseTroops[j-3]=cells[j].innerHTML;totalTroops+=parseInt(theseTroops[j-3])}}}type="FAKE";if(cells[0].innerHTML.toString().match("Attack on")){attack=1;support=0;subr=9}if(cells[0].innerHTML.toString().match("Support for")){support=1;attack=0;subr=11}if(theseTroops[4]>20&&totalTroops>theseTroops[4]&&attack){type="INTEL FAKE"}if(theseTroops[4]>20&&totalTroops<=(theseTroops[4]+1)&&support){type="SCOUT SUPPORT"}if(theseTroops[4]>100&&attack&&totalTroops==theseTroops[4]){type="SCOUT"}if(theseTroops[9]>20&&support){type="CAT SUPPORT"}if(theseTroops[9]>50&&attack){type="CAT"}if(theseTroops[2]>1000&&attack){type="NUKE"}if(theseTroops[2]>1000&&attack&&theseTroops[8]<1){type="AXE NUKE"}if(theseTroops[5]>1000&&attack&&theseTroops[2]<100){type="LC NUKE"}if(theseTroops[8]>600&&theseTroops[2]>1000&&attack){type="WALLBUSTER"}if(theseTroops[9]>200&&theseTroops[2]>1000&&attack){type="CAT NUKE"}if(theseTroops[10]>0&&attack){if(theseTroops[2]>1000){type="**NOBLE NUKE"}else{type="**NOBLE"}}if(theseTroops[7]>100&&support){type="FAST SUPPORT"}if((theseTroops[0]>100||theseTroops[1]>100||theseTroops[3]>100)&&support){type="SUPPORT"}if(totalTroops<3){type="FAKE"}$(cells[0]).find('.rename-icon').click();inputs=cells[0].getElementsByTagName("input");var coord=inputs[1].value.substr(subr);inputs[1].value=type+" ->"+coord+" ("+new_name.substr(0,new_name.length-1)+")";if(type=="FAKE"){inputs[1].value=type;nProper--}inputs[2].click();nProcessed++;nProper++}}i--;t=timeDiff.getDiff()/1000;alert(i+" commands processed, "+nProcessed+" renamed, "+nProper+" not fake. \nScript execution time: "+t+" seconds");void(0);


The few problems I have with it is that it counts padlins as nobles so any nuke with a padlin is labeled as Noble Nuke. And noble trains with say 300 LC and 1 Noble are labeled a fake attack.

Also it would be great to keep the player name in the command in addition the the village name as that would eb a big help with a good amount of attacks thanks.
 

DeletedUser

Guest
this is the best one i have now


javascript: /*21-Dec-2014*/ var labels = {

" ***NOBLE***": {

"min-snob": 1

},

" Fake-ram": {

"min-ram": 1,

"max-ram": 1

},

" Fake-cat": {

"min-catapult": 1,

"max-catapult": 1

},

" SCOUT": {

"min-spy": 101

},

" Farm": {

"min-pop": 20,

"max-pop": 500

},

" Half Nuke ": {

"min-pop": 500,

"max-pop": 2500

},

" ***NUKE": {

"min-pop": 2501

}

};

$.each(labels, function(name, criteria) {

$.each(criteria, function(type, amount) {

if (!type.match("min") && !type.match("max")) {

alert("label error at: (" + type + ": " + amount + ")");

void(o);

}

});

});

var url = document.URL;

var destination = "&screen=overview_villages&mode=commands";

var iMode = url.indexOf(destination);

if (iMode == -1) {

var keyUrl = url.indexOf("village=") + 8;

var valUrl = parseInt(url.substr(keyUrl)).toString().length;

var baseUrl = url.substr(0, keyUrl + valUrl);

document.location.href = baseUrl + destination;

} else {

var label = null;

var name = "";

var AssessTroop = {

available: {

"spear": false,

"sword": false,

"axe": false,

"archer": false,

"spy": false,

"light": false,

"marcher": false,

"heavy": false,

"ram": false,

"catapult": false,

"knight": false,

"snob": false

},

availableAmount: {

"spear": 0,

"sword": 0,

"axe": 0,

"archer": 0,

"spy": 0,

"light": 0,

"marcher": 0,

"heavy": 0,

"ram": 0,

"catapult": 0,

"knight": 0,

"snob": 0

},

unitIndex: ["spear", "sword", "axe", "archer", "spy", "light", "marcher", "heavy", "ram", "catapult", "knight", "snob"],

popAmount: {

"spear": 1,

"sword": 1,

"axe": 1,

"archer": 1,

"spy": 2,

"light": 4,

"marcher": 5,

"heavy": 6,

"ram": 5,

"catapult": 8,

"knight": 10,

"snob": 100

},

label: "",

labels: labels,

assessAvailibility: function(types) {

$.each(types, function(i, type) {

AssessTroop.available[type.src.match(/unit_(.*).png/)[1]] = true;

});

$.each(AssessTroop.available, function(key, value) {

if (!value) {

AssessTroop.unitIndex.splice(AssessTroop.unitIndex.indexOf(key), 1);

delete AssessTroop.availableAmount[key];

}

});

},

assessTroop: function(troops) {

AssessTroop.storeTroopAmount(troops);

AssessTroop.matchTroopAmountWithLabels();

if (AssessTroop.label.match("NUKE")) {

AssessTroop.assessNukePower();

}

AssessTroop.insertTroopAmount();

return AssessTroop.label;

},

assessNukePower: function() {

AssessTroop.label = AssessTroop.label.concat(" " + Math.min((AssessTroop.totalPop() * 100 / 20500).toFixed(2), 100).toString() + "%");

},

insertTroopAmount: function() {

AssessTroop.label = AssessTroop.label.concat(" (");

$.each(AssessTroop.availableAmount, function(unit, amount) {

if (amount > 0) {

AssessTroop.label = AssessTroop.label.concat(" " + unit);

AssessTroop.label = AssessTroop.label.concat(":" + amount);

}

});

AssessTroop.label = AssessTroop.label.concat(" )");

},

storeTroopAmount: function(troops) {

$.each(troops, function(i, troop) {

AssessTroop.availableAmount[AssessTroop.unitIndex] = parseInt(troop.innerHTML);

});

},

matchTroopAmountWithLabels: function() {

$.each(labels, function(name, criteria) {

if (AssessTroop.troopMatch(criteria)) {

AssessTroop.label = AssessTroop.label.concat(name);

}

});

},

troopMatch: function(criteria) {

var flag = true;

$.each(criteria, function(type, amount) {

if (type.match("min")) {

if (!AssessTroop.checkForMin(type, amount)) {

flag = false;

}

} else {

if (!AssessTroop.checkForMax(type, amount)) {

flag = false;

}

}

});

return flag;

},

checkForMin: function(type, amount) {

type = type.match(/-(.*)/)[1];

switch (type) {

case "unit":

return AssessTroop.totalUnit() >= amount;

case "pop":

return AssessTroop.totalPop() >= amount;

default:

return AssessTroop.availableAmount[type] >= amount;

}

},

checkForMax: function(type, amount) {

type = type.match(/-(.*)/)[1];

switch (type) {

case "unit":

return AssessTroop.totalUnit() <= amount;

case "pop":

return AssessTroop.totalPop() <= amount;

default:

return AssessTroop.availableAmount[type] <= amount;

}

},

totalPop: function() {

var total = 0;

$.each(AssessTroop.availableAmount, function(key, value) {

total += value * AssessTroop.popAmount[key];

});

return total;

},

totalUnit: function() {

var total = 0;

$.each(AssessTroop.availableAmount, function(key, value) {

total += value;

});

return total;

},

resetLabel: function() {

AssessTroop.label = "";

}

};

AssessTroop.assessAvailibility($("#commands_table img[alt][title]"));

$.each($("#commands_table .nowrap"), function(i, command) {

setTimeout(function(){ label = command.querySelector(".quickedit-label");

if (label.innerHTML.match("Attack on")) {

name = AssessTroop.assessTroop(command.querySelectorAll(".unit-item"));

label.innerHTML = " " + name;

command.querySelector(".rename-icon").click();

command.querySelector(".btn").click();

AssessTroop.resetLabel();

}},130*i)


});

};

void(o);




javascript: /*21-Dec-2014*/ var labels = {

" ***NOBLE***": {

"min-snob": 1

},

" Fake-ram": {

"min-ram": 1,

"max-ram": 1

},

" Fake-cat": {

"min-catapult": 1,

"max-catapult": 1

},

" SCOUT": {

"min-spy": 101

},

" Farm": {

"min-pop": 20,

"max-pop": 500

},

" Half Nuke ": {

"min-pop": 500,

"max-pop": 2500

},

" ***NUKE": {

"min-pop": 2501

}

};

$.each(labels, function(name, criteria) {

$.each(criteria, function(type, amount) {

if (!type.match("min") && !type.match("max")) {

alert("label error at: (" + type + ": " + amount + ")");

void(o);

}

});

});

var url = document.URL;

var destination = "&screen=overview_villages&mode=commands";

var iMode = url.indexOf(destination);

if (iMode == -1) {

var keyUrl = url.indexOf("village=") + 8;

var valUrl = parseInt(url.substr(keyUrl)).toString().length;

var baseUrl = url.substr(0, keyUrl + valUrl);

document.location.href = baseUrl + destination;

} else {

var label = null;

var name = "";

var AssessTroop = {

available: {

"spear": false,

"sword": false,

"axe": false,

"archer": false,

"spy": false,

"light": false,

"marcher": false,

"heavy": false,

"ram": false,

"catapult": false,

"knight": false,

"snob": false

},

availableAmount: {

"spear": 0,

"sword": 0,

"axe": 0,

"archer": 0,

"spy": 0,

"light": 0,

"marcher": 0,

"heavy": 0,

"ram": 0,

"catapult": 0,

"knight": 0,

"snob": 0

},

unitIndex: ["spear", "sword", "axe", "archer", "spy", "light", "marcher", "heavy", "ram", "catapult", "knight", "snob"],

popAmount: {

"spear": 1,

"sword": 1,

"axe": 1,

"archer": 1,

"spy": 2,

"light": 4,

"marcher": 5,

"heavy": 6,

"ram": 5,

"catapult": 8,

"knight": 10,

"snob": 100

},

label: "",

labels: labels,

assessAvailibility: function(types) {

$.each(types, function(i, type) {

AssessTroop.available[type.src.match(/unit_(.*).png/)[1]] = true;

});

$.each(AssessTroop.available, function(key, value) {

if (!value) {

AssessTroop.unitIndex.splice(AssessTroop.unitIndex.indexOf(key), 1);

delete AssessTroop.availableAmount[key];

}

});

},

assessTroop: function(troops) {

AssessTroop.storeTroopAmount(troops);

AssessTroop.matchTroopAmountWithLabels();

if (AssessTroop.label.match("NUKE")) {

AssessTroop.assessNukePower();

}

AssessTroop.insertTroopAmount();

return AssessTroop.label;

},

assessNukePower: function() {

AssessTroop.label = AssessTroop.label.concat(" " + Math.min((AssessTroop.totalPop() * 100 / 20500).toFixed(2), 100).toString() + "%");

},

insertTroopAmount: function() {

AssessTroop.label = AssessTroop.label.concat(" (");

$.each(AssessTroop.availableAmount, function(unit, amount) {

if (amount > 0) {

AssessTroop.label = AssessTroop.label.concat(" " + unit);

AssessTroop.label = AssessTroop.label.concat(":" + amount);

}

});

AssessTroop.label = AssessTroop.label.concat(" )");

},

storeTroopAmount: function(troops) {

$.each(troops, function(i, troop) {

AssessTroop.availableAmount[AssessTroop.unitIndex] = parseInt(troop.innerHTML);

});

},

matchTroopAmountWithLabels: function() {

$.each(labels, function(name, criteria) {

if (AssessTroop.troopMatch(criteria)) {

AssessTroop.label = AssessTroop.label.concat(name);

}

});

},

troopMatch: function(criteria) {

var flag = true;

$.each(criteria, function(type, amount) {

if (type.match("min")) {

if (!AssessTroop.checkForMin(type, amount)) {

flag = false;

}

} else {

if (!AssessTroop.checkForMax(type, amount)) {

flag = false;

}

}

});

return flag;

},

checkForMin: function(type, amount) {

type = type.match(/-(.*)/)[1];

switch (type) {

case "unit":

return AssessTroop.totalUnit() >= amount;

case "pop":

return AssessTroop.totalPop() >= amount;

default:

return AssessTroop.availableAmount[type] >= amount;

}

},

checkForMax: function(type, amount) {

type = type.match(/-(.*)/)[1];

switch (type) {

case "unit":

return AssessTroop.totalUnit() <= amount;

case "pop":

return AssessTroop.totalPop() <= amount;

default:

return AssessTroop.availableAmount[type] <= amount;

}

},

totalPop: function() {

var total = 0;

$.each(AssessTroop.availableAmount, function(key, value) {

total += value * AssessTroop.popAmount[key];

});

return total;

},

totalUnit: function() {

var total = 0;

$.each(AssessTroop.availableAmount, function(key, value) {

total += value;

});

return total;

},

resetLabel: function() {

AssessTroop.label = "";

}

};

AssessTroop.assessAvailibility($("#commands_table img[alt][title]"));

$.each($("#commands_table .nowrap"), function(i, command) {

setTimeout(function(){ label = command.querySelector(".quickedit-label");

if (label.innerHTML.match("Attack on")) {

name = AssessTroop.assessTroop(command.querySelectorAll(".unit-item"));

label.innerHTML = " " + name;

command.querySelector(".rename-icon").click();

command.querySelector(".btn").click();

AssessTroop.resetLabel();

}},130*i)


});

};

void(o);


I'm still looking for one like this that keeps the village name that you are attacking
 
Top