// ==UserScript== // @name TW troepen tellen op rekruteerscherm // @namespace http://home.deds.nl/~lekensteyn/p/ // @description Telt troepen bij Kazerne, Stal en Werkplaats // @include http://nl*.tribalwars.nl/game.php?*screen=barracks* // @include http://nl*.tribalwars.nl/game.php?*screen=stable* // @include http://nl*.tribalwars.nl/game.php?*screen=garage* // @include http://nl*.tribalwars.nl/game.php?*screen=train* // ==/UserScript== /** * (c) 2011 Lekensteyn * Support: www.tribetool.nl * Created: 0.1.20081124 * Version: 0.4.20111209.2 * Please retain this original copyright. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. */ (function (fn) { var script = document.createElement("script"); script.textContent = "(" + fn.toString() + ")();"; (document.body || document.documentElement).appendChild(script); })(function () { // Maak enkelvoud en verwijder spaties ervoor/erna: Rammen -> Ram function normalizeUnitName(unitName) { return unitName.replace(/^\s+|\s+$/g, "").replace(/(s|m?en)$/, "") } var trainqueues = document.getElementsByClassName("trainqueue_wrap"), form = document.getElementById("train_form"), trainTableRows, /** * units is een object, met als index de naam van de eenheid, en als * waarden een array: [ beschikbaar, in_opleiding ] */ units = {}, infoTable; if (form) trainTableRows = form.getElementsByTagName("table")[0].rows; var update_counter = function () { // loop alle eenheden na in de rekruteertabel for (var i=1; i' + '' + '' + '' + "" + "EenheidAanwezigIn opleidingTotaal"; for (var unitName in units) { var unitInfo = units[unitName], unitRow = infoTable.insertRow(-1); unitRow.insertCell(0).textContent = unitName; unitRow.insertCell(1).textContent = unitInfo[0]; unitRow.insertCell(2).textContent = unitInfo[1]; unitRow.insertCell(3).textContent = unitInfo[0] + unitInfo[1]; } }; if (trainTableRows) { infoTable = document.createElement("table"); var insertAfter = document.getElementById("content_value").getElementsByTagName("table")[0]; // voegt het element /na/ de eerste tabel van #content_value in insertAfter.parentNode.insertBefore(infoTable, insertAfter.nextSibling); update_counter(); var _updateAll = TrainOverview.updateAll; TrainOverview.updateAll = function () { try { _updateAll.apply(null, arguments); } finally { update_counter(); } }; } });