SHARE
TWEET

Untitled

a guest May 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Timing Farm
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match       https://us41.tribalwars.us/game.php?village=*&screen=am_farm*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. var TIME_BETWEEN_REFRESH = 1200000;
  12. var MIN_LC = 2;
  13. var MAX_DISTANCE = 35;
  14.  
  15. //var villas = "(480|490) K44#(479|484) K44#(481|491) K44#(475|484) K44#(475|485) K44#(475|480) K44#(472|478) K44#(477|478) K44#(470|477) K44#(472|487) K44#(473|479) K44#(470|481) K44#(467|476) K44#(469|485) K44#(466|493) K44";
  16.  
  17. //var villasArray = villas.split("#");
  18.  
  19. var villageIndex = 2;
  20. var j = 1;
  21. var t = 0;
  22. var interval = Math.floor(Math.random()*(1200-800+1)+800);
  23.  
  24.  
  25. (function main() {
  26.     'use strict';
  27.     var reloadTime = Math.floor(Math.random()*(70000-50000+1)+50000);
  28.     var captcha = document.getElementsByClassName("rc-anchor-logo-img rc-anchor-logo-img-portrait")[0];
  29.     if (captcha!=null){
  30.         return;
  31.     }
  32.  
  33.     //So algumas vilas farmam
  34.     //var coords = document.getElementById("menu_row2").getElementsByClassName("nowrap")[2].textContent;
  35.     //console.log(coords);
  36.     //if(!villasArray.includes(coords))
  37.     //  document.getElementById("village_switch_right").click();
  38.  
  39.     setTimeout(AttackLoop, 1000);
  40.  
  41.     console.log(reloadTime);
  42.     //setTimeout(function(){ document.getElementById("village_switch_right").click(); }, TIME_BETWEEN_REFRESH);
  43.     setTimeout(function(){ location.reload(); }, TIME_BETWEEN_REFRESH);
  44.  
  45. })();
  46.  
  47. function AttackLoop(){
  48.     var farmModel = 9;
  49.     var distance;
  50.     var wall;
  51.     var lastTime;
  52.     var lastHour;
  53.     var lastMinute;
  54.     var spy = document.getElementById('spy').innerHTML;
  55.     var light = document.getElementById('light').innerHTML;
  56.     var haul;
  57.  
  58.     try{
  59.         var x = document.getElementById('plunder_list');
  60.         var y = x.getElementsByTagName('tr')[villageIndex];
  61.         distance = y.getElementsByTagName('td')[7].innerHTML;
  62.         distance = parseFloat(distance.replace(/\s/g, "").replace(",", "."));
  63.         wall = y.getElementsByTagName('td')[6].innerHTML;
  64.         lastTime = y.getElementsByTagName('td')[4].innerHTML;
  65.         lastTime = lastTime.substring(9);
  66.         lastHour = parseInt(lastTime.split(':')[0]);
  67.         lastMinute = parseInt(lastTime.split(':')[1]);
  68.         haul = y.getElementsByTagName('td')[2];
  69.         haul = haul.getElementsByTagName('img')[0];
  70.     }
  71.     catch(Exception){
  72.         console.log("Finished this round");
  73.         return;
  74.     }
  75.     var lightInt = parseInt(light);
  76.     if(lightInt == 0){
  77.         console.log("Finished this round");
  78.         return;
  79.     }
  80.  
  81.  
  82.     farmModel = 8;
  83.  
  84.     ////// RESTRICOES DE MODELOS ///////
  85.     if((wall == "0" || wall == "?") && distance < MAX_DISTANCE){
  86.  
  87.     // 8 = A, 9 = B, 10 = C
  88.  
  89.         var coordsRow = y.getElementsByTagName('td')[3].textContent;
  90.         var coord = coordsRow.substr(1);
  91.         coord = coord.substr(1,7);
  92.  
  93.          farmModel = 9;
  94.  
  95.         if(parseInt(light) < MIN_LC) return;
  96.  
  97.        // if(y.getElementsByTagName('td')[2].getElementsByTagName('img')[0].src == "https://dsus.innogamescdn.com/8.153/39901/graphic/max_loot/1.png"){
  98.          //   farmModel = 9;
  99.         //}
  100.         try{
  101.             var z = y.getElementsByTagName('td')[farmModel];
  102.             var w = z.getElementsByTagName('a')[0];
  103.             w.click();
  104.         }
  105.         catch(Exception){
  106.             try{
  107.                 farmModel = 9;
  108.                 z = y.getElementsByTagName('td')[farmModel];
  109.                 w = z.getElementsByTagName('a')[0];
  110.                 w.click();
  111.             }
  112.             catch(Exception){
  113.                 return;
  114.             }
  115.         }
  116.  
  117.         var farmType = "C";
  118.         if(farmModel == 9)
  119.             farmType = "B";
  120.         else if(farmModel == 8)
  121.             farmType = "A";
  122.  
  123.         console.log("Farmed village: " + villageIndex + " with " + farmType + " , wall=" + wall + " , distance=" + distance + " , interval =" + interval);
  124.     }
  125.     //else{
  126.     //    console.log("Skipped farm - Wall too high");
  127.     //}
  128.     villageIndex += 1;
  129.     j = j + 1;
  130.     interval = Math.floor(Math.random()*(1100-700+1)+700);
  131.     setTimeout(AttackLoop, interval);
  132.  
  133. }
  134.  
  135. function detectRobot(){
  136.     var reloadTime = Math.floor(Math.random()*(70000-50000+1)+50000);
  137.     var xpathResult = document.evaluate("(//text()[contains(., 'robot')])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  138.     var node=xpathResult.singleNodeValue;
  139.     if (node==null)
  140.       return false;
  141.     return true;
  142. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top