Coinbrawl

try to take over the world!

Versión del día 09/03/2016. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name         Coinbrawl
// @version      0.39
// @description  try to take over the world!
// @author       You
// @match        https://www.coinbrawl.com/*
// @grant        none
// @namespace https://greasyfork.org/users/25633
// ==/UserScript==

//ads
$('div.panel-game-content:first').hide();
$('div.col-sm-9 > center').hide();
$('div.col-sm-3').hide();

if (location.href=="https://www.coinbrawl.com/recaptcha"){

    track = '';
    for(i=0;i<8;) {
        i++;
        for(k = l = 11025; k--;) {
            track += String.fromCharCode(
                Math.sin(k/88400*2*Math.PI*481.34)
                * Math.min((l-k)/83,k/l)
                * (i%5&&i%9-3?88:33) + 128);
        }
    }
    player = new Audio('data:audio/wav;base64,UklGRkRiBQBXQVZFZm10IBAAAAA\
BAAEARKwAAESsAAABAAgAZGF0YSBi'+btoa('\5\0'+track));
    player.play();
    setTimeout(function(){ 
        top.location.href = "https://www.coinbrawl.com";
    },30000);

} else if ( $("li.active a[href='/").length == 1 ){ //On main page

    $('div.col-sm-6').hide();
    $('div.col-sm-4').hide();
    $('div.col-sm-8').hide();

    var BANKLIMIT = 2752170;
    var withdrawLimit = 200000;

    var startS = setInterval(function(){

        var rawSta = $('#quick-stats > div > div > ul > li:nth-child(5) > span.value > span:nth-child(2)').text();
        var rawTok = $('#quick-stats > div > div > ul > li:nth-child(6) > span.value > span:nth-child(2)').text();
        var gold = $('#quick-stats > div > div > ul > li:nth-child(7) > span.value.text-success > span:nth-child(2)').text();
        var cuurentBank = $('#quick-stats > div > div > ul > li:nth-child(9) > span.value.text-success > span:nth-child(2)').text();

        var stamina = rawSta.split("/");
        var token = rawTok.split("/");

        //console.log('Stamina: ', parseInt(stamina[0]), "/", parseInt(stamina[1]));
        //console.log('Tokens: ', parseInt(token[0]), "/", parseInt(token[1]));
        //console.log('Gold: ', gold);

        if (token[0] > 0 ) {
            setTimeout(function(){ 
                attackUser();
            },600);
            $('tbody:first > tr').find('td > a')[0].click();
        } 

        if ( stamina[0] > 0 ) {
            setTimeout(function(){ 
                $('#npc-battle-table > div > table > tbody > tr:nth-child(6) > td:nth-child(5) > a')[0].click();
            },300);
        }

        if ( gold > withdrawLimit && cuurentBank < BANKLIMIT ) {
            console.log('[BOT] Gold limit reached. Depositing to Bank');
            top.location.href = "https://www.coinbrawl.com/bank/deposit_max";
        } 

        if (cuurentBank == BANKLIMIT) {
            console.log('[BOT] Bank has reached limit!');
            //clearInterval(startS);
        }


    },3000);


    /*   var searchArena = $('#battle-table > div > p > a')[0];
    searchArena.onclick=function(){
        setTimeout(function(){
            attackUser();
        },1000);
    };*/

} else if ( $("li.active a[href='/bank").length == 1 ){ 

    var gotoArena = setTimeout(function(){
        top.location.href = "https://www.coinbrawl.com/";
    },3000);

}



function attackUser(){
    var trows = $('tbody:first > tr');
    var lastHighIndex = 0;
    var lastHighPercentage = 0;

    trows.each(function(index, element){

        var winGreen = $(this).find('div.text-success').text().replace('%','');
        var winYellow = $(this).find('div.text-warning').text().replace('%','');

        //var winRed = $(this).find('div.text-danger').text().replace('%','');


        if (  winGreen > lastHighPercentage ) {
            lastHighIndex = index;
            lastHighPercentage = winGreen;
        } else if (  winYellow > lastHighPercentage ) {
            lastHighIndex = index;
            lastHighPercentage = winYellow;
        }


        /*else if (  $(this).find('strong.text-success').html() > 5000 && $(this).find('div.text-warning').length > 0 ) {
            $(this).find('td > a')[0].click();
            cooldown = 0;
            return;
        } else if (  $(this).find('strong.text-success').html() > 100000 && $(this).find('div.text-danger').length > 0 ) {
            $(this).find('td > a')[0].click();
        }*/

    });

    try {
        trows[lastHighIndex].find('td > a')[0].click();
    } catch(err) {
    }
}