Bots

try to take over the world!

13.11.2017 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Bots
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  try to take over the world!
// @author       yorares
// @match        http*://*.triburile.ro/*
// @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 split = url.split(/=|&/);
    var idSat = split[1];
    var urlCheck = url.slice(-13);
    var urlCheckConfirm = url.slice(-12);
    var barbArray = JSON.parse(localStorage.getItem("coordonateBarb"));
    var r;
    var i;
    var waitTimeSw = Math.floor((Math.random() * (40000 - 10000 + 1)) + 10000);
    var obiect = JSON.parse(localStorage.getItem("obiect"));
    console.log(obiect);
    if(url.slice(-18) == "?session_expired=1"){$(".world_button_active:first").click();console.log(url.slice(-18));}
    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 barbsInteli(){
        if(obiect.modificat === 1){
            var cheile = Object.keys(obiect);
            var unde = cheile.indexOf("modificat");
            console.log("cheile si unde",cheile,typeof unde);
            for(i=0;i < unde;i++){
                obiect[cheile[i]].splice(1,1,1);
                console.log("modificat",obiect,i);
                var valorile = Object.values(obiect[cheile[i]]);
                for(j=3;j<valorile.length;j++){
                    console.log("al doilea for",j);
                    if(barbArray.indexOf(valorile[j]) == -1){
                        valorile.splice(j,1);
                    }
                }
                obiect[cheile[i]] = valorile;
                localStorage.setItem("obiect", JSON.stringify(obiect));
            }
            obiect.modificat = 0;
        }
        if(obiect[idSat].length < 3){obiect[idSat].splice(2,1,3);}
        if(obiect[idSat][1] === 1){
            for(i=0;i<barbArray.length;i++){

                var x = Math.abs(Number(obiect[idSat][0].split('|')[0]) - Number(barbArray[i].split('|')[0]));
                var y = Math.abs(Number(obiect[idSat][0].split('|')[1]) - Number(barbArray[i].split('|')[1]));

                var distanta = Math.sqrt((x*x) + (y*y));
                console.log("-1 ala",obiect[idSat].indexOf(barbArray[i]),distanta);
                if(distanta <= obiect.distanta && obiect[idSat].indexOf(barbArray[i]) == -1){
                    obiect[idSat].push(barbArray[i]);
                }
            }
            obiect[idSat].splice(1,1,0);
        }

        if(obiect[idSat][2] >= obiect[idSat].length){obiect[idSat].splice(2,1,3);}
        $(".target-input-field").val(obiect[idSat][obiect[idSat][2]]);
        obiect[idSat].splice(2,1,obiect[idSat][2]+1);
        localStorage.setItem("obiect", JSON.stringify(obiect));
        setTimeout(function(){$("#target_attack").click();}, waitTime);

    }
    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);}
    }
    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"));

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

    }
    if(url.slice(-55) == "game.php?screen=welcome&intro&oscreen=overview_villages"){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);
        if(secunde >= 7800000){}
        console.log(secunde/7800000,"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);
        });


    }

});