SHARE
TWEET

Pop counter

SophieDebleeckere May 31st, 2020 639 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript: if (document.URL.match(/mode=commands/)) {
  2.     var troopsArray = new Array();
  3.     var numvil = 0;
  4.     var main = $("#commands_table")[0];
  5.     var names = new Array();
  6.     var vilCoords = new Array();
  7.     var village = new Array();
  8.     var CurVill;
  9.     var totalFarmSpace
  10.     var units = ['Spears', 'Swords', 'Axes', 'Archers', 'Scouts', 'Light Cal', 'Mounted Archers', 'Heavy Cal', 'Rams', 'Cats', 'Nobleman'];
  11.     var farmused = ['1', '1', '1', '1', '2', '4', '5', '6', '5', '8', '100'];
  12.     var rows = main.getElementsByTagName('tr');
  13.     for (var j = 1; j < rows.length; j++) {
  14.         var cells = rows[j].getElementsByTagName('td');
  15.         if ($(cells[0]).text().match(/Support/) == "Support") {
  16.             CurVill = $(cells[0]).text().split(/\(/);
  17.             CurVill = CurVill[CurVill.length - 1];
  18.             CurVill = CurVill.match(/\d+\|\d+/);
  19.             var val = 0;
  20.             if (vilCoords[CurVill] == null) {
  21.                 village.push(CurVill);
  22.                 vilCoords[CurVill] = new Array();
  23.                 var p = 0;
  24.                 for (var k = 3; k <= (cells.length - 1); k++) {
  25.                     val = cells[k].firstChild.nodeValue;
  26.                     if (!val) {
  27.                         val = cells[k].firstChild.innerHTML.replace(/<[^>]*>/g, '').replace(/\s+/, '').match(/\d+/)[0];
  28.                     }
  29.                     vilCoords[CurVill][p] = parseInt(val);
  30.                     p = p + 1;
  31.                 }
  32.             } else {
  33.                 var p = 0;
  34.                 for (var k = 3; k <= (cells.length - 1); k++) {
  35.                     val = cells[k].firstChild.nodeValue;
  36.                     if (!val) {
  37.                         val = cells[k].firstChild.innerHTML.replace(/<[^>]*>/g, '').replace(/\s+/, '').match(/\d+/)[0];
  38.                     }
  39.                     vilCoords[CurVill][p] += parseInt(val);
  40.                     p = p + 1;
  41.                 }
  42.             }
  43.         }
  44.     }
  45.     var msg = "Total Support Sent<br>" + "---------------------------------<br>";
  46.     for (var g = 0; g < village.length; g++) {
  47.         msg += "Sent -- ";
  48.         var villageCoords = village[g];
  49.         var troops = vilCoords[villageCoords];
  50.         var farmspace = 0;
  51.         for (var h = 0; h <= 9; h++) {
  52.             if (troops[h] == 0) {
  53.             } else {
  54.                 msg += units[h] + ": " + troops[h] + " ";
  55.                 farmspace += parseInt(troops[h] * farmused[h]);
  56.             }
  57.         }
  58.         msg += "to [village]" + village[g] + "[/village] (total population is: " + farmspace +")<br>";
  59.         totalFarmSpace+=farmspace
  60.     }
  61.     msg+="Total packets sent: "+(totalFarmSpace/1000);
  62.     console.log(msg);
  63.  
  64.     function openPopup() {
  65.         var TheNewWin = window.open('', 'name', 'height=255,width=800, toolbar=no,directories=no,status=no,menubar=no');
  66.         TheNewWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd"><html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
  67.         TheNewWin.document.write('<head><title>Popup<\/title><\/head><body style="overflow:hidden" bgcolor="#ffffff"> <p>' + msg + '<\/p>');
  68.         TheNewWin.document.write(' <hr \/> <p align="right"><a href="#" onclick="self.close(); return false;">Close');
  69.         TheNewWin.document.write(' Window<\/a><\/p> <\/body><\/html>');
  70.     }
  71.  
  72.     openPopup();
  73. } else {
  74.     self.location = "http://" + window.location.hostname + "/game.php?screen=overview_villages&mode=commands";
  75. }
  76. void (0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top