Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name massive atack
- // @include *pt62.tribalwars.com.pt*
- // @grant none
- // ==/UserScript==
- (function() {
- var tempo = 355;
- var x = 0;
- var FakesPorAldeia = 1;
- var coords = '499|586';
- var doc = document;
- var url = document.URL;
- var cookieName = "farmeruk";
- var cookieNameTent = "tentcookie";
- var maxTentativas = 1;
- var data;
- var h2 = document.getElementsByTagName('h2');
- var Praca = false;
- var EnviarAtaque = false;
- for (i = 0; i < h2.length; i++)
- {
- if (h2[i].innerHTML == "Praça de Reuniões (nível 1)")
- {
- Praca = true;
- }
- else if(h2[i].innerHTML.search("Confirmar ataque a") != -1)
- {
- EnviarAtaque=true;
- }
- }
- if (Praca == EnviarAtaque)
- {
- alert("Algo correu mal");
- }
- var tentCookie = document.cookie.match('(^|;) ?' + cookieNameTent + '=([^;]*)(;|$)');
- if (tentCookie !== null)
- {
- var numTentativas = parseInt(tentCookie[2]);
- } else
- {
- data = new Date(2019, 11, 11);
- document.cookie = cookieNameTent + "=0;expires=" + data.toGMTString();
- var numTentativas = 0;
- }
- if (Praca)
- {
- if (document.getElementsByClassName("error_box")[0] !== undefined)
- {
- var erroFaltaUnid = document.getElementsByClassName("error_box");
- for (i = 0; i < erroFaltaUnid.length && !found; i++)
- {
- if (erroFaltaUnid[i].innerHTML.search("Não existem unidades suficientes") != -1)
- {
- setTimeout(function () { console.log("aahahahah"); }, 5000000);
- location.reload(1);
- }
- }
- }
- if (doc.forms[0].x.value !== "")
- {
- var index = 0; farmcookie = document.cookie.match('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
- if (farmcookie !== null)
- {
- index = parseInt(farmcookie[2]);
- }
- if (index >= coords.length)
- {
- index = 0;
- }
- index = index + 1;
- cookie_date = new Date(2019, 11, 11);
- document.cookie = cookieName + "=" + index + ";expires=" + cookie_date.toGMTString();
- var link = document.getElementsByClassName("quickbar_link");
- for (i = 0; i < link.length; i++)
- {
- if (link[i].href.search(/screen=place/) != -1)
- {
- window.location.href = link[i].href;
- }
- }
- }
- else
- {
- if (window.frames.length > 0)
- {
- doc = window.main.document;
- }
- url = document.URL;
- coords = coords.split(" ");
- var index = 0;
- farmcookie = document.cookie.match('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
- if (farmcookie !== null)
- {
- index = parseInt(farmcookie[2]);
- }
- if (index >= coords.length)
- {
- index = 0;
- }
- if (document.getElementsByClassName("command-list-count") [0] !== undefined)
- {
- var numAtaques = document.getElementsByClassName("command-list-count") [0].innerHTML;
- }
- else
- {
- var numAtaques = 0;
- }
- if (numAtaques < FakesPorAldeia)
- {
- if (numTentativas <= maxTentativas)
- {
- if(4000 > document.getElementById("units_entry_all_axe").text.replace(/[^0-9]/g,''))
- document.getElementById("village_switch_right").click();
- else{
- $("a.troop_template_selector").click();
- }
- /* if(1 > document.getElementById("units_entry_all_catapult").text.replace(/[^0-9]/g,'') || 54 > document.getElementById("units_entry_all_spy").text.replace(/[^0-9]/g,''))
- document.getElementById("village_switch_right").click();
- doc.forms[0].catapult.value = 1;
- doc.forms[0].spy.value = 55;
- */
- coords = coords[index];
- coords = coords.split("|");
- index = index + 1;
- cookie_date = new Date(2019, 11, 11);
- document.cookie = cookieName + "=" + index + ";expires=" + cookie_date.toGMTString();
- doc.forms[0].x.value = coords[0];
- doc.forms[0].y.value = coords[1];
- var delay = 200;
- setTimeout(function() {
- document.forms[0].attack.click();
- }, delay);
- }
- else
- {
- data = new Date(2019, 11, 11);
- document.cookie = cookieNameTent + "=0;expires=" + data.toGMTString();
- document.getElementById("village_switch_right").click();
- }
- }
- else
- {
- document.getElementById("village_switch_right").click();
- }
- }
- }
- else if (EnviarAtaque) {
- var BNCheck = document.getElementsByClassName("error");
- var found = false;
- for (i = 0; i < BNCheck.length && !found; i++) {
- if (BNCheck[i].innerHTML == "Bónus noturno ativo!") {
- found = true;
- }
- }
- var time = $(".relative_time").text();
- var hora = parseInt(time.charAt(time.length-8) + time.charAt(time.length-7));
- if (found) {
- var link = document.getElementsByClassName("quickbar_link");
- for (i = 0; i < link.length; i++) {
- if (link[i].href.search(/screen=place/) != -1) {
- numTentativas = numTentativas + 1;
- data = new Date(2019, 11, 11);
- document.cookie = cookieNameTent + "=" + numTentativas + ";expires=" + data.toGMTString();
- window.location.href = link[i].href;
- }
- }
- }
- /* else if(time.includes("hoje") == false || hora < 9 ){
- document.getElementById("village_switch_right").click();
- }*/
- else {
- document.forms[0].troop_confirm_go.click();
- }
- }
- else
- {
- alert("Corra o script apartir da praça de reuniões");
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement