Is there a command that makes the function resume?

Asked

Viewed 140 times

0

I am new in this area. I created this bot for a betting site. I wonder if there is a command for the function to return 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);
  • 2

    Please do not type text in the upper box, it impairs reading. Edit the question by accessing the [Edit] link and write normally. Take advantage and do the [tour] to learn the basics of the site and read the [Ask] guide. To properly format your code, use the button {} of the editor.

  • Why do you start with $("input").val("10");, then there’s $("input").val("11"); and all the others are $("input").val("13");?

  • this script is only a test actually when hit the green the amount bet is multiplied po 14X

  • the reason is 1.1x each bet, but the question is as follows, if it goes green I would like you to return to the beginning of the function

  • there is Alum Return command that I can use for example if green Return

  • this site is formed by 3 colors, red, green, and black, in case the bet on green wins 14x the value bet, with this function I put the value you want to play on green, but I wanted a command that identified the green and returned to base again, ie at the first bet

Show 1 more comment

1 answer

1

Well, your script would be something roughly equivalent to that:

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); sets what it does when it is clicked. In case, it starts all over again.

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

  • The "" + ~~m serves to convert the m for whole and then for string.

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

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

  • But there is no possibility to use a Return?

  • Test your script on the site and did not work, would have another solution using the same function, exePlo when leaving the green I use a function that identifies it

  • @Ramonsilva I think a return will not do what you want. The function fazApostas() just creates a lot of events to run in the future and dies immediately. Anything that comes back wouldn’t be very useful. You could even use a Promises/callback engine, but that probably wouldn’t be what you want.

  • @Ramonsilva You may want to use this: https://api.jquery.com/size/

  • @Ramonsilva What went wrong in the script?

  • The site is this https://csgoatse.com/, note that under the roulette has the results, there I would like to use the Return, for example when a green appears in the history my script starts again.

  • He doesn’t bet, just nothing happened when I threw him on the console

  • @Ramonsilva Script edited. Look at the last line.

  • Now I found buddy, gave but he ta betting several times in a row I would like a bet every 25 seconds

  • If you go green I want you to return to base 10

  • @Ramonsilva Reply edited.

  • The essential thing was a javscript that identified the green, I would like him to start betting after 30 rounds without going green and when the green came out he waited 30 more rounds to start betting again

  • This stopped the page because it repeats countless times the bets

  • @Ramonsilva So I don’t know yet. I left the two attempts there in case you or someone else find another solution.

  • Thanks for the help anyway

Show 10 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.