Bots

try to take over the world!

Per 02-11-2017. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         Bots
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       yorares
// @match        http*://*.triburile.ro/*&screen=place*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @grant        none
// ==/UserScript==

jQuery(function($){
    var scris;
    $("body").prepend("<div id='botStart' style=' position: absolute; top: 40%; left: 5%'></div>");
    if(JSON.parse(localStorage.getItem("start")) === 0){scris = "Start";}else{scris = "Stop";}
    $("#botStart").append("<input type='button' value='"+scris+"' style=' font-size: 20px; background-color: white;color: black;border: 2px solid #f44336;'/>");
    $("#botStart").click(function(){if(JSON.parse(localStorage.getItem("start")) === 0){localStorage.setItem("start", JSON.stringify(1));location.reload();}else{localStorage.setItem("start", JSON.stringify(0));}location.reload();});
    if($("#popup_box_daily_bonus").length >0){$("#popup_box_daily_bonus").remove();}
    var waitTime = Math.floor((Math.random() * 5000) + 1);
    var villArray = JSON.parse(localStorage.getItem("sate"));
    var url = window.location.href;
    var urlCheck = url.slice(-13);
    var urlCheckConfirm = url.slice(-12);
    var barbArray = JSON.parse(localStorage.getItem("coordonateBarb"));
    var r;
    var waitTimeSw = Math.floor((Math.random() * (100000 - 40000 + 1)) + 40000);
    if (typeof JSON.parse(localStorage.getItem("iLastSate")) !== 'undefined' && JSON.parse(localStorage.getItem("iLastSate")) !== null){r = JSON.parse(localStorage.getItem("iLastSate"));}else{
        r = 0;
        localStorage.setItem("iLastSate", JSON.stringify(r));}
    if(r >= JSON.parse(localStorage.getItem("sate")).length){ r = 0;localStorage.setItem("iLastSate", JSON.stringify(r));}
    function removeBarb(){
        var indexN = barbArray.indexOf(JSON.parse(localStorage.getItem("lastBarb")));
        barbArray.splice(indexN,1);
        localStorage.setItem("coordonateBarb", JSON.stringify(barbArray));
    }
    function setUnits(unit,barb,ce,ind){
        if(ce === 0){$("#unit_input_spear").val(unit);}
        else if(ce === 1){$("#unit_input_sword").val(unit);}
        else if(ce === 2){$("#unit_input_axe").val(unit);}
        else if(ce === 3){$("#unit_input_light").val(unit);}
        $(".target-input-field").val(barb);
        localStorage.setItem("lastBarb", JSON.stringify(barb));
        ind +=1;
        localStorage.setItem("iLast", JSON.stringify(ind));
        setTimeout(function(){$("#target_attack").click();}, waitTime);
    }
    function changeSat(ind,vill){
        ind+=1;
        localStorage.setItem("iLastSate", JSON.stringify(ind));
        if(ind > JSON.parse(localStorage.getItem("sate")).length){ ind = 1;localStorage.setItem("iLastSate", JSON.stringify(ind));}
        setTimeout(function(){window.location.href = vill;}, waitTimeSw);
    }
    function getValuesAv(){
        var availableUnitsLight = $("#units_entry_all_light").html();
        availableUnitsLight = availableUnitsLight.replace('(','');
        availableUnitsLight = availableUnitsLight.replace(')','');
        availableUnitsLight = parseInt(availableUnitsLight);
        var availableUnitsSpear = $("#units_entry_all_spear").html();
        availableUnitsSpear = availableUnitsSpear.replace('(','');
        availableUnitsSpear = availableUnitsSpear.replace(')','');
        availableUnitsSpear = parseInt(availableUnitsSpear);
        var availableUnitsSword = $("#units_entry_all_sword").html();
        availableUnitsSword = availableUnitsSword.replace('(','');
        availableUnitsSword = availableUnitsSword.replace(')','');
        availableUnitsSword = parseInt(availableUnitsSword);
        var availableUnitsAxe = $("#units_entry_all_axe").html();
        availableUnitsAxe = availableUnitsAxe.replace('(','');
        availableUnitsAxe = availableUnitsAxe.replace(')','');
        availableUnitsAxe = parseInt(availableUnitsAxe);
        console.log(availableUnitsLight,"light");
        console.log(availableUnitsSpear,"spear");
        console.log(availableUnitsSword,"sword");
        console.log(availableUnitsAxe,"axe");
        return [availableUnitsSpear, availableUnitsSword, availableUnitsAxe, availableUnitsLight];
    }

    if(urlCheck == "&screen=place" && JSON.parse(localStorage.getItem("start")) === 1){

        var avUnits = getValuesAv();
        var pulei = JSON.parse(localStorage.getItem("pulei"));
        var sabie = JSON.parse(localStorage.getItem("sabie"));
        var topor = JSON.parse(localStorage.getItem("topor"));
        var calut = JSON.parse(localStorage.getItem("calut"));
        var i;
        if (typeof JSON.parse(localStorage.getItem("iLast")) !== 'undefined' && JSON.parse(localStorage.getItem("iLast")) !== null){i = JSON.parse(localStorage.getItem("iLast"));}else{
            i = 0;
            localStorage.setItem("iLast", JSON.stringify(i));}
        if(i >= JSON.parse(localStorage.getItem("coordonateBarb")).length){ i = 0;localStorage.setItem("iLast", JSON.stringify(i));}

        if (pulei <= avUnits[0] && pulei !== 0 && pulei !== 'undefined' && pulei !== null){setUnits(pulei,barbArray[i],0,i);console.log(i);}
        else if (sabie <= avUnits[1] && sabie !== 0 && sabie !== 'undefined' && sabie !== null){setUnits(sabie,barbArray[i],1,i);console.log(i);}
        else if (topor <= avUnits[2] && topor !== 0 && topor !== 'undefined' && topor !== null){setUnits(topor,barbArray[i],2,i);console.log(i);}
        else if (calut <= avUnits[3] && calut !== 0 && calut !== 'undefined' && calut !== null){setUnits(calut,barbArray[i],3,i);console.log(i);}
        else {console.log(waitTimeSw);changeSat(r,villArray[r]);}

    }
    if(urlCheckConfirm === "&try=confirm" && JSON.parse(localStorage.getItem("start")) === 1){
        if($(".error_box").length >0){changeSat(r,villArray[r]);}
        var jucator = $("td");
        for (j=0;j<jucator.length;j++){if(jucator[j].innerHTML == "Jucător:"){removeBarb();changeSat(r,villArray[r]);}if(jucator[j].innerHTML == "Durată:"){var timp = jucator[j+1].innerHTML;}console.log(j);}
        var timpArr = timp.split(":");
        var secunde = (parseInt(timpArr[2]) * 1000) + ( parseInt(timpArr[1]) * 60000) + (parseInt(timpArr[0]) * 3600000);
        var minute = parseInt(timpArr[1]) * 60000;
        var ore = parseInt(timpArr[0]) * 3600000;
        var timpTotal = 0;

        console.log(secunde/10000,"Secunde");
        setTimeout(function(){ $("#troop_confirm_go").click();}, waitTime);
    }else if (urlCheckConfirm === "&try=confirm" && JSON.parse(localStorage.getItem("start")) === 0){
        $("#content_value").append("<input type='text' id='cand' style='width:300px;font-size:25px;' placeholder=' ex: 2017-10-27 02:16:00'/><input type='button' value='Ataca' id='ataca'/><p id='show' style='font-size:20px;'>Ex: 2017-10-27 02:16:00</p>");
        $("#ataca").click(function(){
            function msToTime(duration) {
                var milliseconds = parseInt((duration%1000)/100), seconds = parseInt((duration/1000)%60), minutes = parseInt((duration/(1000*60))%60), hours = parseInt((duration/(1000*60*60))%24);

                hours = (hours < 10) ? "0" + hours : hours;
                minutes = (minutes < 10) ? "0" + minutes : minutes;
                seconds = (seconds < 10) ? "0" + seconds : seconds;

                return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
            }

            var jucator = $("td");
            for (j=0;j<jucator.length;j++){if(jucator[j].innerHTML == "Durată:"){var timp = jucator[j+1].innerHTML;}console.log(j);}
            var timpArr = timp.split(":");
            var secunde = (parseInt(timpArr[2]) * 1000) + ( parseInt(timpArr[1]) * 60000) + (parseInt(timpArr[0]) * 3600000);
            var diff = Math.abs(new Date($("#cand").val()) - new Date()) -secunde;
            setInterval(function(){diff = Math.abs(new Date($("#cand").val()) - new Date()) -secunde;}, 100);

            setTimeout(function(){ $("#troop_confirm_go").click();}, diff);
            console.log(diff);
            setInterval(function(){$("#show").html(msToTime(diff));}, 100);
        });


    }

});