Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Dorfübersicht
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Ergänzt die Dorfübersicht um Informationen aus Raubzügen und Truppenrekrutierung
  6. // @author You
  7. // @match https://*.die-staemme.de/game.php?*screen=overview*
  8. // @grant none
  9. // @require https://ds-legends.com/library.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Setzt Logindaten fest
  16. user = "phchecker17";
  17. password = "test";
  18.  
  19. // Erstellt ein Widget in der Dorfübersicht
  20. function createWidget(id, title, rows, before, element) {
  21. var table = "<table width='100%'><tr class='nowrap'>";
  22. var i;
  23. for (i = 0; i < rows.length; i++)
  24. table += "<td width='70'><span class='icon " + rows[i].icon + "'></span> " + rows[i].title + "</td><td>" + rows[i].content + "</tr>";
  25. table += "</table>";
  26. 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>";
  27. if (before)
  28. $(element).before(content);
  29. else
  30. $(element).after(content);
  31. }
  32.  
  33. // Lädt Daten aus der Datenbank und initialisiert das UI
  34. var scavenge_gain, scavenge_efficiency, recruiting_wood, recruiting_stone, recruiting_iron = 0;
  35. var ready = -5;
  36.  
  37. getData('scavenge_gain', function(val) { scavenge_gain = val; ready++; });
  38. getData('scavenge_efficiency', function(val) { scavenge_efficiency = val; ready++; });
  39. getData('recruiting_wood', function(val) { recruiting_wood = val; ready++; });
  40. getData('recruiting_stone', function(val) { recruiting_stone = val; ready++; });
  41. getData('recruiting_iron', function(val) { recruiting_iron = val; ready++; });
  42.  
  43. function initializeUI() {
  44. if (ready == 0) {
  45. var wood = $("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(0)").html().match(/\d+/)[0];
  46. var stone = $("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(1)").html().match(/\d+/)[0];
  47. var iron = $("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(2)").html().match(/\d+/)[0];
  48.  
  49. createWidget("show_overall", "Gesamtproduktion", [{icon:"header wood", title:"Holz", content:"<strong>" + (parseInt(wood) + parseInt(scavenge_gain) - parseInt(recruiting_wood)) + "</strong> pro Stunde</td>"}, {icon:"header stone", title:"Lehm", content:"<strong>" + (parseInt(stone) + parseInt(scavenge_gain) - parseInt(recruiting_stone)) + "</strong> pro Stunde</td>"}, {icon:"header iron", title:"Eisen", content:"<strong>" + (parseInt(iron) + parseInt(scavenge_gain) - parseInt(recruiting_iron)) + "</strong> pro Stunde</td>"}], true, "div#show_prod");
  50. createWidget("show_scavenge", "Raubzüge", [{icon:"header ressources", title:"Ertrag", content:"<strong>" + scavenge_gain + "</strong> pro Stunde</td>"}, {icon:"", title:"", content:"<strong>" + scavenge_efficiency + "%</strong> Effizienz</td>"}], false, "div#show_prod");
  51. createWidget("show_recruiting", "Rekrutierung", [{icon:"header wood", title:"Holz", content:"<strong>-" + recruiting_wood + "</strong> pro Stunde</td>"}, {icon:"header stone", title:"Lehm", content:"<strong>-" + recruiting_stone + "</strong> pro Stunde</td>"}, {icon:"header iron", title:"Eisen", content:"<strong>-" + recruiting_iron + "</strong> pro Stunde</td>"}], false, "div#show_prod");
  52. } else {
  53. setTimeout(function() { initializeUI(); }, 200);
  54. }
  55. }
  56.  
  57. setTimeout(function() { initializeUI(); }, 200);
  58.  
  59.  
  60. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement