Da ich heute so nett bin:
javascript:
var doc;
if (top.frames.length > 1){
doc = (top.frames[1].document.URL.match('game.php') == 'game.php') ? top.frames[1].document : top.frames[0].document;
} else {
doc = document;
};
if (!doc.URL.match('mode=units')){
UI.InfoMessage('Du musst dich auf der "Truppen"-Übersicht befinden!',3000,true);
} else {
script(doc);
};
function script(doc){
if (typeof(world) == 'undefined') {
units = Array(Array(0,'Speerträger'),Array(1,'Schwertkämpfer'),Array(2,'Axtkämpfer'),Array(3,'Bogenschützen'),Array(4,'Späher'),Array(5,'Leichte Kavallerie'),Array(6,'Berittener Bogenschütze'),Array(7,'Schwere Kavallerie'),Array(8,'Rammböcke'),Array(9,'Katapulte'));
} else {
if (world == 'oBogen') {
units = Array(Array(0,'Speerträger'),Array(1,'Schwertkämpfer'),Array(2,'Axtkämpfer'),Array(3,'Bogenschützen'),Array(4,'Späher'),Array(5,'Leichte Kavallerie'),Array(6,'Schwere Kavallerie'),Array(7,'Rammböcke'),Array(8,'Katapulte'));
} else if (world == 'mBogen') {
units = Array(Array(0,'Speerträger'),Array(1,'Schwertkämpfer'),Array(2,'Axtkämpfer'),Array(3,'Bogenschützen'),Array(4,'Späher'),Array(5,'Leichte Kavallerie'),Array(6,'Berittener Bogenschütze'),Array(7,'Schwere Kavallerie'),Array(8,'Rammböcke'),Array(9,'Katapulte'));
}
}
units_count = units.length;
troops = new Array(units_count);
for (var i = 0; i < units_count; i++)
troops=0;
village_count = 0;
var troops_cells = document.getElementById('units_table').getElementsByTagName('td');
for (var x = 0; x < troops_cells.length; x++) {
if (typeof(art) == 'undefined') {
if (troops_cells[x].firstChild.nodeValue == 'eigeni' || troops_cells[x].firstChild.nodeValue == 'uswärts' || troops_cells[x].firstChild.nodeValue == 'untrwägs') {
village_count += 1;
next = troops_cells[x].nextSibling;
for (var y = 0; y < units_count; y++) {
do {next = next.nextSibling;} while (next.nodeType != 1)
troops[y] += parseInt(next.firstChild.nodeValue);
}
}
} else {
if (world == 'Im Dorf' && troops_cells[x].firstChild.nodeValue == 'eigeni') {
village_count += 1;
next = troops_cells[x].nextSibling;
for (var y = 0; y < units_count; y++) {
do {next = next.nextSibling;} while (next.nodeType != 1)
troops[y] += parseInt(next.firstChild.nodeValue);
}
} else if (world == 'uswärts' && troops_cells[x].firstChild.nodeValue == 'uswärts' || troops_cells[x].firstChild.nodeValue == 'untrwägs') {
village_count += 1;
next = troops_cells[x].nextSibling;
for (var y = 0; y < units_count; y++) {
do {next = next.nextSibling;} while (next.nodeType != 1)
troops[y] += parseInt(next.firstChild.nodeValue);
}
} else if (world == 'Gesamt' && troops_cells[x].firstChild.nodeValue == 'eigeni' || troops_cells[x].firstChild.nodeValue == 'uswärts' || troops_cells[x].firstChild.nodeValue == 'untrwägs') {
village_count += 1;
next = troops_cells[x].nextSibling;
for (var y = 0; y < units_count; y++) {
do {next = next.nextSibling;} while (next.nodeType != 1)
troops[y] += parseInt(next.firstChild.nodeValue);
};
}
}
}
if (village_count > 0) {
var output ='';
for (var i = 0; i < units_count; i++) {
output += "<tr><td style='color:blue'> " + units[1] + " </td><td style='color:red; text-align:right'>" + troops + "</td></tr>";
}
width = 330;
height = 290;
left = (screen.width - width)/2;
top = (screen.height - height)/2;
popup = window.open('','','width='+width+', height='+height+', top='+top+', left='+left);
popup.document.write("<html><head><title>Truppenübersicht</title></head><body style='background-color: #F1EBDD; border: 1px #804000 solid'><br><table>" + output + "</table><br></body></html>");
} else {
UI.InfoMessage('Fehler! Keine Dörfer/Truppen gefunden!',3000,true);
}
};
das ist der Truppenzähler für ch^^