Guest User

Untitled

a guest
Mar 20th, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Dorfübersicht
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  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 http://ds.cratetrader.com/library.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. user = "phchecker17";
  16. password = "test";
  17.  
  18. var wood = $("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(0)").html().replace(" ", "");
  19. var stone = $("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(1)").html().replace(" ", "");
  20. var iron = $("div#show_prod").children("div.widget_content").children("table").children("tbody").children("tr").children("td").children("strong:eq(2)").html().replace(" ", "");
  21.  
  22. var scavenge_gain = 0;
  23. var scavenge_efficiency = 0;
  24. var recruiting_wood = 0;
  25. var recruiting_stone = 0;
  26. var recruiting_iron = 0;
  27.  
  28. function createBox(id, title, rows, before, element) {
  29. var table = "<table width='100%'><tr class='nowrap'>";
  30. var i;
  31. for (i = 0; i < rows.length; i++)
  32. table += "<td width='70'><span class='icon " + rows[i].icon + "'></span> " + rows[i].title + "</td><td>" + rows[i].content + "</tr>";
  33. table += "</table>";
  34. 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>";
  35. if (before)
  36. $(element).before(content);
  37. else
  38. $(element).after(content);
  39. }
  40.  
  41. var ready = -5;
  42.  
  43. getData('scavenge_gain', function(val) { scavenge_gain = val; ready++; });
  44. getData('scavenge_efficiency', function(val) { scavenge_efficiency = val; ready++; });
  45. getData('recruiting_wood', function(val) { recruiting_wood = val; ready++; });
  46. getData('recruiting_stone', function(val) { recruiting_stone = val; ready++; });
  47. getData('recruiting_iron', function(val) { recruiting_iron = val; ready++; });
  48.  
  49. function createBoxes() {
  50. if (ready >= 0) {
  51. createBox("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");
  52. createBox("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");
  53. createBox("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");
  54. } else {
  55. setTimeout(function() { createBoxes(); }, 200);
  56. }
  57. }
  58.  
  59. setTimeout(function() { createBoxes(); }, 200);
  60.  
  61. })();
Add Comment
Please, Sign In to add comment