Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Dorfübersicht
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Ergänzt die Dorfübersicht um Informationen aus Raubzügen und Truppenrekrutierung
- // @author You
- // @match https://*.die-staemme.de/game.php?*screen=overview*
- // @grant none
- // @require https://ds-legends.com/library.js
- // ==/UserScript==
- (function() {
- 'use strict';
- // Setzt Logindaten fest
- user = "phchecker17";
- password = "test";
- // Initialisiert notwendige Variablen
- var scavenge_gain, scavenge_efficiency, recruiting_wood, recruiting_stone, recruiting_iron, wood, stone, iron, ready;
- // Aktualisiert die Produktionszahlen in der Dorfübersicht
- function update() {
- ready = -5;
- getData('scavenge_gain', function(val) { scavenge_gain = val; ready++; });
- getData('scavenge_efficiency', function(val) { scavenge_efficiency = val; ready++; });
- getData('recruiting_wood', function(val) { recruiting_wood = val; ready++; });
- getData('recruiting_stone', function(val) { recruiting_stone = val; ready++; });
- getData('recruiting_iron', function(val) { recruiting_iron = val; ready++; });
- function calculateNewValues() {
- if (ready == 0) {
- $("strong#total_wood").html(format(parseInt(wood) + parseInt(scavenge_gain) - parseInt(recruiting_wood)));
- $("strong#total_stone").html(format(parseInt(stone) + parseInt(scavenge_gain) - parseInt(recruiting_stone)));
- $("strong#total_iron").html(format(parseInt(iron) + parseInt(scavenge_gain) - parseInt(recruiting_iron)));
- $("strong#scavenge_gain").html(format(scavenge_gain));
- $("strong#scavenge_efficiency").html(scavenge_efficiency);
- $("strong#recruiting_wood").html("-" + format(recruiting_wood));
- $("strong#recruiting_stone").html("-" + format(recruiting_stone));
- $("strong#recruiting_iron").html("-" + format(recruiting_iron));
- } else {
- setTimeout(function() { calculateNewValues(); }, 200);
- }
- }
- setTimeout(function() { calculateNewValues(); }, 200);
- }
- // Erstellt ein Widget in der Dorfübersicht
- function createWidget(id, title, rows, before, element) {
- var table = "<table width='100%'><tr class='nowrap'>";
- var i;
- for (i = 0; i < rows.length; i++)
- table += "<td width='70'><span class='icon " + rows[i].icon + "'></span> " + rows[i].title + "</td><td>" + rows[i].content + "</tr>";
- table += "</table>";
- var content = "<div id='" + id + "' class='vis moveable widget'><h4 class='head'><img class='widget-button' src='graphic/minus.png'>" + title + "</h4><div class='widget_content' style='display: block'>" + table + "</div></div>";
- if (before)
- $(element).before(content);
- else
- $(element).after(content);
- }
- // Lädt Daten aus der Datenbank und initialisiert das UI
- ready = -5;
- getData('scavenge_gain', function(val) { scavenge_gain = val; ready++; });
- getData('scavenge_efficiency', function(val) { scavenge_efficiency = val; ready++; });
- getData('recruiting_wood', function(val) { recruiting_wood = val; ready++; });
- getData('recruiting_stone', function(val) { recruiting_stone = val; ready++; });
- getData('recruiting_iron', function(val) { recruiting_iron = val; ready++; });
- function initializeUI() {
- if (ready == 0) {
- wood = parseInt($("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(0)").html().replace("<span class=\"grey\">.</span>", "").match(/\d+/)[0]);
- stone = parseInt($("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(1)").html().replace("<span class=\"grey\">.</span>", "").match(/\d+/)[0]);
- iron = parseInt($("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(2)").html().replace("<span class=\"grey\">.</span>", "").match(/\d+/)[0]);
- setData("production_wood", wood);
- setData("production_stone", stone);
- setData("production_iron", iron);
- createWidget("show_overall", "Gesamtproduktion", [{icon:"header wood", title:"Holz", content:"<strong id='total_wood'>" + format(parseInt(wood) + parseInt(scavenge_gain) - parseInt(recruiting_wood)) + "</strong> pro Stunde</td>"}, {icon:"header stone", title:"Lehm", content:"<strong id='total_stone'>" + format(parseInt(stone) + parseInt(scavenge_gain) - parseInt(recruiting_stone)) + "</strong> pro Stunde</td>"}, {icon:"header iron", title:"Eisen", content:"<strong id='total_iron'>" + format(parseInt(iron) + parseInt(scavenge_gain) - parseInt(recruiting_iron)) + "</strong> pro Stunde</td>"}], true, "div#show_prod");
- createWidget("show_scavenge", "Raubzüge", [{icon:"header ressources", title:"Ertrag", content:"<strong id='scavenge_gain'>" + format(scavenge_gain) + "</strong> pro Stunde</td>"}, {icon:"", title:"", content:"<strong id='scavenge_efficiency'>" + scavenge_efficiency + "%</strong> Effizienz</td>"}], false, "div#show_prod");
- createWidget("show_recruiting", "Rekrutierung", [{icon:"header wood", title:"Holz", content:"<strong id='recruiting_wood'>-" + format(recruiting_wood) + "</strong> pro Stunde</td>"}, {icon:"header stone", title:"Lehm", content:"<strong id='recruiting_wood'>-" + format(recruiting_stone) + "</strong> pro Stunde</td>"}, {icon:"header iron", title:"Eisen", content:"<strong id='recruiting_iron'>-" + format(recruiting_iron) + "</strong> pro Stunde</td>"}], false, "div#show_prod");
- } else {
- setTimeout(function() { initializeUI(); }, 200);
- }
- }
- setTimeout(function() { initializeUI(); }, 200);
- setInterval(function() { update(); }, 60000);
- })();
Add Comment
Please, Sign In to add comment