Advertisement
SophieDebleeckere

Untitled

May 31st, 2020
861
0
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=0;
  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.         msg+="Total packets sent: "+(parseInt(farmspace)/1000);
  60.         totalFarmSpace+=parseInt(farmspace);
  61.     }
  62.     msg+="Total packets sent to all villages: "+(parseInt(totalFarmSpace)/1000);
  63.     console.log(msg);
  64.  
  65.     function openPopup() {
  66.         var TheNewWin = window.open('', 'name', 'height=255,width=800, toolbar=no,directories=no,status=no,menubar=no');
  67.         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">');
  68.         TheNewWin.document.write('<head><title>Popup<\/title><\/head><body style="overflow:hidden" bgcolor="#ffffff"> <p>' + msg + '<\/p>');
  69.         TheNewWin.document.write(' <hr \/> <p align="right"><a href="#" onclick="self.close(); return false;">Close');
  70.         TheNewWin.document.write(' Window<\/a><\/p> <\/body><\/html>');
  71.     }
  72.  
  73.     openPopup();
  74. } else {
  75.     self.location = "http://" + window.location.hostname + "/game.php?screen=overview_villages&mode=commands";
  76. }
  77. void (0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement