Is there a command that restarts?

0

I'm new to this area. I created this bot for a betting site. I would like to know if there is any command for the function to go back to the beginning when green.

$("input").val("10");
setTimeout(function(){
$(".btn-bet.green").click();
    }, 100);
setTimeout(function(){
$("input").val("11");
$(".btn-bet.green").click();
    }, 25000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 50000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 75000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 100000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 125000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 150000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 175000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 200000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 225000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 250000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 275000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 300000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 325000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 350000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 375000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 400000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 425000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 450000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 475000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 500000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 525000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 550000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 575000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 600000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 625000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 650000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 675000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 700000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 725000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 750000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 775000);
setTimeout(function(){
$("input").val("13");
$(".btn-bet.green").click();
    }, 800000);
    
asked by anonymous 05.09.2017 / 23:42

1 answer

1

Well, your script would be something equivalent to something like this:

Attempt 1:

function fazApostas() {
    var jaFoi = false;
    $(".btn-bet.green").click(function() {
        jaFoi = true;
        fazApostas();
    });
    var m = 10;
    for (var i = 0; i < 40; i++) {
        setTimeout(function() {
            if (jaFoi) return;
            $("input").val("" + ~~m);
            m *= 1.1;
            $(".btn-bet.green").click();
        }, i * 25000 + 100);
    }
}
fazApostas();

Attempt 2:

function fazApostas() {
    var m = 10;
    function aumentarAposta() {
        $("input").val("" + ~~m);
        if ($(".btn-bet.green").length === 0) {
            m *= 1.1;
            setTimeout(aumentarAposta, 25000);
        } else {
            $(".btn-bet.green").click(fazApostas);
            $(".btn-bet.green").click();
        }
    }
    setTimeout(aumentarAposta, 100);
}
fazApostas();
  • The $(".btn-bet.green").click(fazApostas); defines what it does when clicked. In case, it starts all over again.

  • The m *= 1.1; makes the bet amount increase each time.

  • The "" + ~~m is used to convert m to integer and then to string.

  • Each iteration of aumentarAposta calls another iteration 25 seconds later.

  • The $(".btn-bet.green").length === 0 checks whether the button is present or not.

05.09.2017 / 23:58