Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Timing Farm
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://us41.tribalwars.us/game.php?village=*&screen=am_farm*
- // @grant none
- // ==/UserScript==
- var TIME_BETWEEN_REFRESH = 1200000;
- var MIN_LC = 2;
- var MAX_DISTANCE = 35;
- //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";
- //var villasArray = villas.split("#");
- var villageIndex = 2;
- var j = 1;
- var t = 0;
- var interval = Math.floor(Math.random()*(1200-800+1)+800);
- (function main() {
- 'use strict';
- var reloadTime = Math.floor(Math.random()*(70000-50000+1)+50000);
- var captcha = document.getElementsByClassName("rc-anchor-logo-img rc-anchor-logo-img-portrait")[0];
- if (captcha!=null){
- return;
- }
- //So algumas vilas farmam
- //var coords = document.getElementById("menu_row2").getElementsByClassName("nowrap")[2].textContent;
- //console.log(coords);
- //if(!villasArray.includes(coords))
- // document.getElementById("village_switch_right").click();
- setTimeout(AttackLoop, 1000);
- console.log(reloadTime);
- //setTimeout(function(){ document.getElementById("village_switch_right").click(); }, TIME_BETWEEN_REFRESH);
- setTimeout(function(){ location.reload(); }, TIME_BETWEEN_REFRESH);
- })();
- function AttackLoop(){
- var farmModel = 9;
- var distance;
- var wall;
- var lastTime;
- var lastHour;
- var lastMinute;
- var spy = document.getElementById('spy').innerHTML;
- var light = document.getElementById('light').innerHTML;
- var haul;
- try{
- var x = document.getElementById('plunder_list');
- var y = x.getElementsByTagName('tr')[villageIndex];
- distance = y.getElementsByTagName('td')[7].innerHTML;
- distance = parseFloat(distance.replace(/\s/g, "").replace(",", "."));
- wall = y.getElementsByTagName('td')[6].innerHTML;
- lastTime = y.getElementsByTagName('td')[4].innerHTML;
- lastTime = lastTime.substring(9);
- lastHour = parseInt(lastTime.split(':')[0]);
- lastMinute = parseInt(lastTime.split(':')[1]);
- haul = y.getElementsByTagName('td')[2];
- haul = haul.getElementsByTagName('img')[0];
- }
- catch(Exception){
- console.log("Finished this round");
- return;
- }
- var lightInt = parseInt(light);
- if(lightInt == 0){
- console.log("Finished this round");
- return;
- }
- farmModel = 8;
- ////// RESTRICOES DE MODELOS ///////
- if((wall == "0" || wall == "?") && distance < MAX_DISTANCE){
- // 8 = A, 9 = B, 10 = C
- var coordsRow = y.getElementsByTagName('td')[3].textContent;
- var coord = coordsRow.substr(1);
- coord = coord.substr(1,7);
- farmModel = 9;
- if(parseInt(light) < MIN_LC) return;
- // if(y.getElementsByTagName('td')[2].getElementsByTagName('img')[0].src == "https://dsus.innogamescdn.com/8.153/39901/graphic/max_loot/1.png"){
- // farmModel = 9;
- //}
- try{
- var z = y.getElementsByTagName('td')[farmModel];
- var w = z.getElementsByTagName('a')[0];
- w.click();
- }
- catch(Exception){
- try{
- farmModel = 9;
- z = y.getElementsByTagName('td')[farmModel];
- w = z.getElementsByTagName('a')[0];
- w.click();
- }
- catch(Exception){
- return;
- }
- }
- var farmType = "C";
- if(farmModel == 9)
- farmType = "B";
- else if(farmModel == 8)
- farmType = "A";
- console.log("Farmed village: " + villageIndex + " with " + farmType + " , wall=" + wall + " , distance=" + distance + " , interval =" + interval);
- }
- //else{
- // console.log("Skipped farm - Wall too high");
- //}
- villageIndex += 1;
- j = j + 1;
- interval = Math.floor(Math.random()*(1100-700+1)+700);
- setTimeout(AttackLoop, interval);
- }
- function detectRobot(){
- var reloadTime = Math.floor(Math.random()*(70000-50000+1)+50000);
- var xpathResult = document.evaluate("(//text()[contains(., 'robot')])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
- var node=xpathResult.singleNodeValue;
- if (node==null)
- return false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement