Settings

try to take over the world!

Versione datata 02/11/2017. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Settings
// @namespace    http://tampermonkey.net/
// @version      0.2
// @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 url = window.location.href;
    var coordonatePlus = url.slice(-8);
    var control = coordonatePlus.slice(0,1);
    var coordonate = coordonatePlus.slice(1,8);
    var coordonateBune = coordonate.replace(";","|");
    var barbArray = JSON.parse(localStorage.getItem("coordonateBarb"));
    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 sate = JSON.parse(localStorage.getItem("sate"));

    function getVillage(){
        let sate = JSON.parse(localStorage.getItem("sate"));
        let unde = sate.indexOf(url);
        if(unde == -1){
        sate.push(url);
        localStorage.setItem("sate", JSON.stringify(sate));}
    }
    function deleteVillage(){
        let sate = JSON.parse(localStorage.getItem("sate"));
        let unde = sate.indexOf(url);
        if(unde !== -1){sate.splice(unde,1);
                        localStorage.setItem("sate", JSON.stringify(sate));
                       }
    }

    function getUnits(){
        var pulei = parseInt($("#pulei").val());
        localStorage.setItem("pulei", JSON.stringify(pulei));
        var sabie = parseInt($("#sabie").val());
        localStorage.setItem("sabie", JSON.stringify(sabie));
        var topor = parseInt($("#topor").val());
        localStorage.setItem("topor", JSON.stringify(topor));
        var calut = parseInt($("#calut").val());
        localStorage.setItem("calut", JSON.stringify(calut));
    }

    if (typeof localStorage.getItem("coordonateBarb") !== 'undefined' && localStorage.getItem("coordonateBarb") !== null){}else{
        let barbArray = [];
        localStorage.setItem("coordonateBarb", JSON.stringify(barbArray));}
    if (typeof localStorage.getItem("sate") !== 'undefined' && localStorage.getItem("sate") !== null){}else{
        let sateArray = [];
        localStorage.setItem("sate", JSON.stringify(sateArray));}
    console.log(url.slice(-13));
    if(url.slice(0,43) == "https://ro59.triburile.ro/game.php?village=" && url.slice(-13) == "&screen=place"){
        $("body").prepend("<div id='piataCentrala' style=' position: absolute; top: 40%; right: 30%'></div>");
        $("#piataCentrala").append("<input type='button' style=' background-color: white;color: black;border: 2px solid #f44336;' value='Delete' id='deleteSat'>");
        $("#piataCentrala").append("<input type='button' style=' background-color: white;color: black;border: 2px solid #f44336;' value='Add' id='addSat'>");
        if(sate.indexOf(url) == "-1"){
            $("#piataCentrala").append("<p>Not Added, "+sate.length+" added until naw</p>");}else{$("#piataCentrala").append("<p>Added, "+sate.length+" villages</p>");}
        $("#addSat").click(function(){
            getVillage();
            location.reload();
        });
        $("#deleteSat").click(function(){
            deleteVillage();
            location.reload();

        });
    }
    if (control === "#"){

        $("body").prepend("<div id='botMeu' style=' position: absolute; top: 40%; right: 30%'></div>");

        $("#botMeu").append("<br><img src='https://dsro.innogamescdn.com/8.101/34907/graphic/unit/unit_spear.png'>");
        $("#botMeu").append("<input type='text' style=' width: 50px;' placeholder='rares' id='pulei'>");
        $("#botMeu").append("<img src='https://dsro.innogamescdn.com/8.101/34907/graphic/unit/unit_sword.png'>");
        $("#botMeu").append("<input type='text' style=' width: 50px;' placeholder='este' id='sabie'>");
        $("#botMeu").append("<img src='https://dsro.innogamescdn.com/8.101/34907/graphic/unit/unit_axe.png'>");
        $("#botMeu").append("<input type='text' style=' width: 50px;' placeholder='smecher' id='topor'>");
        $("#botMeu").append("<img src='https://dsro.innogamescdn.com/8.101/34907/graphic/unit/unit_light.png'>");
        $("#botMeu").append("<input type='text' style=' width: 50px;' placeholder='smecher' id='calut'>");
        $("#botMeu").append("<input type='button' style=' font-size: 16px; background-color: white;color: black;border: 2px solid #f44336;' value='Set Units' id='setUnits'>");
        $("#botMeu").append("<p>Sulite: "+pulei+" Sabii: "+sabie+" Topor: "+topor+" Calut: "+calut+"</p>");
        if(barbArray.indexOf(coordonateBune) == "-1"){
            $("#botMeu").append("<p>Not Added, "+barbArray.length+" added until naw</p>");}else{$("#botMeu").append("<p>Added, "+barbArray.length+" villages</p>");}
        $("#botMeu").append("<input type='button' style=' background-color: white;color: black;border: 2px solid #f44336;' value='Delete' id='Delete'>");
        $("#botMeu").append("<input type='button' style=' background-color: white;color: black;border: 2px solid #f44336;' value='Add' id='Add'>");
        $("#Delete").click(function(){
            var indexN = barbArray.indexOf(coordonateBune);
            if(indexN !== -1){barbArray.splice(indexN,1);
                              localStorage.setItem("coordonateBarb", JSON.stringify(barbArray));
                              location.reload();}
        });
        $("#Add").click(function(){
            barbArray.push(coordonateBune);
            localStorage.setItem("coordonateBarb", JSON.stringify(barbArray));
            location.reload();
        });

        $("#setUnits").hover(function(){
            $(this).css("background-color", "red");
            $(this).css("color", "white");
        }, function(){
            $(this).css("background-color", "white");
            $(this).css("color", "red");
        });
        $("#setUnits").click(function(){
            getUnits();
            location.reload();
        });

    }
});