javascript: var markOther=0; var includeName=1;var groups={"F. OFF":{'min':1,'allowOthers':1,'units':{'axe':1000,'light':1000,'ram':50}},"Nobile":{'min':1,'allowOthers':1,'units':{'snob':1}},"Fake":{'min':0,'allowOthers':1,'units':{'spear':1,'axe':1,'archer':1,'spy':1,'light':1,'marcher':1,'heavy':1,'catapult':1}}};var units={ "Spear fighter":"spear", "Swordsman":"sword", "Axeman":"axe", "Archer":"arch", "Scout":"spy", "Light cavalry":"light", "Mounted archer":"march", "Heavy cavalry":"heavy", "Ram":"ram", "Catapult":"catapult", "Paladin":"knight", "Nobleman":"snob" };var currUnits=[];var finalString="";var url=window.location;var data=window.game_data;var player="";var error="This script needs to be run on your own commands";var sendToGroup={};var regex=/\([0-9]*\|[0-9]*\)/g;var commandType, attackInfo, frm, group, clicky;$(function(){ function getGroup(assoc, groups){ var grp=[]; $.each(groups, function(gName, gData) { var matchMin=1; var matchOther=1; var testUnits=gData["units"]; if(gData["min"]==1){ $.each(testUnits, function(unit, num){ if(assoc[unit]===undefined || assoc[unit] < num){ matchMin=0; return false; } }); } else { $.each(testUnits, function(unit, num){ if(assoc[unit] > num){ matchMin=0; return false; } }); } if(gData.allowOthers!==1){ $.each(assoc, function(unit, num){ if(testUnits[unit]===undefined){ matchOther=0; return false; } }); } if(matchOther==1 && matchMin==1){ grp.push(gName); } }); if(grp.length < 1){ return -1; } else { fin=grp.join(" "); return fin; } } switch(data.screen){ case "place": if(/try\=confirm/.test(url)){ commandType=$("h2:first").html(); if(!commandType){ commandType=""; } attackInfo=$('table.vis').eq(0).find("tr").eq(1).find("td").eq(1).find("a").eq(0).html(); if(!attackInfo){ attackInfo=""; }if(includeName==1){ if($('table.vis').eq(0).find("tr").eq(2).find("td").eq(0).html()=="Player:"){ player=$('table.vis').eq(0).find("tr").eq(2).find("td").eq(1).find("a").eq(0).html(); if(!player){ player=""; } } } var ths=$('table.vis').eq(1).find('th'); ths.each(function(){ title=$(this).find("img").eq(0).attr("title"); currUnits.push(title); }); var tds=$('table.vis').eq(1).find("tr").eq(1).find("td"); tds.each(function(i){ if(!$(this).hasClass("hidden")){ sendToGroup[units[currUnits
]]=$(this).html(); } }); frm=$("#new_attack_name"); finalString+=commandType.toUpperCase(); group=getGroup(sendToGroup, groups); if(group!==-1 || markOther==1){editToggle('default_name_span', 'edit_name'); var coords=attackInfo.match(regex); coords=(coords) ? coords[coords.length-1] : ""; finalString+=" "+coords; finalString+=" "+player; finalString+=": "; frm.val("z"+finalString+group); $("#attack_name_btn").click(); } else { alert("Command does not fall under any group"); } } else { alert(error); } break; case "info_command": if(/type\=own/.test(url)){ attackInfo=$('table.vis').eq(0).find("tr").eq(4).find("td").eq(1).find("a").eq(0).html(); if(!attackInfo){ attackInfo=""; } var clicky=$('table.vis').eq(0).find("th").eq(0).find("input").eq(1); str=$("h2").eq(0).html(); commandType=str.match(/[a-zA-Z]* /); commandType=(commandType) ? commandType[0].replace(/ /, "") : ""; if(includeName==1){ if($('table.vis').eq(0).find("tr").eq(3).find("td").eq(1).html()=="Player:"){ player=$('table.vis').eq(0).find("tr").eq(3).find("td").eq(2).find("a").eq(0).html(); if(!player){ player=""; } } } /*unit info*/ var ths=$('table.vis').eq(1).find('th'); ths.each(function(){ title=$(this).find("img").eq(0).attr("title"); currUnits.push(title); }); var tds=$('table.vis').eq(1).find("tr").eq(1).find("td"); tds.each(function(i){ if(!$(this).hasClass("hidden")){ sendToGroup[units[currUnits]]=$(this).html(); } }); frm=$("#editInput"); finalString+=commandType.toUpperCase(); group=getGroup(sendToGroup, groups); if(group!==-1 || markOther==1) { editToggle('label', 'edit'); var coords=attackInfo.match(regex); coords=(coords) ? coords[coords.length-1] : ""; finalString+=" "+coords; finalString+=" "+player; finalString+=": "; frm.val("z"+finalString+group); clicky.click(); } else { alert("Command does not fall under any group"); } } else { alert(error); } break; case "overview_villages": var index; if($("#commands_table")!==-1){ var clicked=false; $('#commands_table').find('tr').eq(0).find("img").each(function(){ title=$(this).attr("title"); currUnits.push(title); }); var trs=$("#commands_table").find("tr:notfirst)"); var z=0; trs.each(function(i){ finalString=""; var send={}; attackInfo=$(this).find("td").eq(0).find("span").eq(0).find("span").eq(0).html(); if(!attackInfo){ attackInfo=""; } if(!attackInfo.match(/z.*/)){ commandType=attackInfo.match(/[a-zA-Z]* /); commandType=(commandType) ? commandType[0].replace(/ /, "") : ""; tds=$('#commands_table').find('tr').eq(i+1).find("td"); tds.each(function(e){ if(e!==0 && e!==1 && e!==2){ if($(this).html()!=="0"){ send[units[currUnits[e-3]]]=$(this).html(); } } }); finalString+=commandType.toUpperCase(); group=getGroup(send, groups); if(group!==-1 || markOther==1){ z=1; editToggle('label['+i+']', 'edit['+i+']'); frm=$("#commands_table").find("tr").eq(i+1).find("input").eq(0); /*filter coords*/ var coords=attackInfo.match(regex); coords=(coords) ? coords[coords.length-1] : ""; finalString+=" "+coords; finalString+=" "+player; finalString+=": "; frm.val("z"+finalString+group); var inputs=$(this).find("span").eq(2).find("input"); inputs.eq(1).click(); } } }); if(z==0){ alert("No commands to rename"); } } break; default: alert(error); return false; break; } });void (0);