rollDice = function() { // wait until button is clickable again if (!$('#double_your_btc_bet_hi_button').prop('disabled')) { // win: double amount / reset to 1 if lost [multiplier] rounds // this option is useful 'cause the max. win profit is 99, so after you spent // 127 [ ((2^7)-1) or 1+2+4+8+16+32+64 ] it's impossible to make profit anymore // since there's no 128 option (so set it max. to 6!) // decrease the multiplier to keep the losses low, but the chance of winning will // also drop if you loose very often consecutively if ($('#double_your_btc_bet_lose').html() !== '' && multiplier < 5) { $('#double_your_btc_2x').click(); multiplier++; // lose: reset to 1 } else { $('#double_your_btc_min').click(); multiplier = 1; } // click hi or lo button randomly if (Math.random() >= 0.5) { $('#double_your_btc_bet_lo_button').click(); } else { $('#double_your_btc_bet_hi_button').click(); } } // wait 250ms before next run. don't set the timeout to zero because if the button is still // unclickable this will cause very high cpu usage! setTimeout(rollDice, 250); }; // initialise multiplier = 1; rollDice();