I wanted to program this script to be sent between x to x hours

Asked

Viewed 577 times

0

// ==UserScript==
// @name        Fakes
// @include     https*tribalwars.com.*place*
// @grant       none
// ==/UserScript==

   var tempo = 300;
   var x = 0;  

javascript:var FakesPorAldeia = 10; 
var sp = 0;var sw = 0;var ax = 0;var scout = 0;var lc = 0;var ma = 0;var hv = 0;var cat = 0;var ra = 0;
var coords ='';
var doc = document;
var url = document.URL;
var cookieName = "farmeruk";
var cookieNameTent = "tentcookie";
var maxTentativas = 15;
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)
            {
                document.getElementById("village_switch_right").click();
                throw ''
            }
        }
    }
    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)
            {
                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];
                doc.forms[0].spy.value = scout;
                doc.forms[0].spear.value = sp;
                doc.forms[0].sword.value = sw;
                doc.forms[0].axe.value = ax;
                doc.forms[0].spy.value = scout;
                doc.forms[0].light.value = lc;
                doc.forms[0].marcher.value = ma;
                doc.forms[0].heavy.value = hv;
                doc.forms[0].ram.value = ra;
                doc.forms[0].catapult.value = cat;
                document.forms[0].attack.click();
            }
            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;
        }
    }
    if (found)
    {
        var link = document.getElementById("village_switch_right").click();
        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
    {
        document.forms[0].troop_confirm_go.click();
    }
}
else
{
    alert("Corra o script apartir da praça de reuniões");
}

  • I would like this Script to send attacks between x and x hours regardless of the day, and variable attack hours can be edited by people For those who want to know what the script refers to is the link (https://www.tribalwars.com.pt)

  • You can explain better within the scope of your question what you want?

  • This is supposed to be a script to be run in the tampermonkey extension that automates a function. And I wonder if it is possible that this process can only select to execute the function if it arrives between the desired hours or is that it just execute the function for example that the commands that it makes to execute arrive between the 10h and the 14h the function does not enter that time period that it uses document.getElementById("village_switch_right").click(); to change where to send. You can change the time when the command arrives

  • If you want more explanation we can always talk by skype or other communication platform and I explain to you better my question

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.