$('body').append('<div style="position:fixed;top:0;left:0;width:100%;height:100%;min-height:100%;text-align: center;z-index:100000;background-color:white;" class=""><table style="margin:0 auto;"><tr><td>balance</td><td id="balance_b"></td></tr><tr><td>win</td><td id="roundwin_b"></td></tr><tr><td>bet</td><td id="current_bet_b"></td></tr><tr><td>time</td><td id="time_b"></td></tr></table></div>'); bconfig = { maxBet: 0.00001024, wait: 1, toggleHilo: false, alertMultiplier: 5 }; initialBalance = parseFloat($('#balance').html()); hilo = 'hi'; multiplier = 1; startTime = new Date().getTime(); rollDice = function() { if ($('#double_your_btc_bet_lose').html() !== '') { $('#double_your_btc_2x').click(); multiplier++; if (bconfig.toggleHilo) toggleHiLo(); } else { setStartBet(); $('#double_your_btc_bet_win').html(''); var cmsg = { lose: $('#double_your_btc_bet_lose').html(), win: $('#double_your_btc_bet_win').html() }; cmsg = JSON.stringify(cmsg); } if (multiplier > bconfig.alertMultiplier) { if (window.confirm("You have already lost " + (Math.pow(2, (multiplier - 1)) - 1) + " and you are about to lose " + Math.pow(2, (multiplier - 1)) + ". Click 'cancel' to reset the bet amount to 1 or 'ok' to take the risk?")) { } else { $('#double_your_btc_min').click(); multiplier = 1; } $('#double_your_btc_bet_' + hilo + '_button').click(); } else { if (parseFloat($('#balance').html()) < (parseFloat($('#double_your_btc_stake').val()) * 2) || parseFloat($('#double_your_btc_stake').val()) > bconfig.maxBet) { $('#double_your_btc_min').click(); multiplier = 1; } $('#double_your_btc_bet_' + hilo + '_button').click(); } // setTimeout(rollDice, (multiplier * bconfig.wait) + Math.round(Math.random() * 100)); }; toggleHiLo = function() { if (hilo === 'hi') { hilo = 'lo'; } else { hilo = 'hi'; } }; setStartBet = function() { $('#double_your_btc_min').click(); multiplier = 1; // if ((Math.random() * 10) > 5) { // } else { // $('#double_your_btc_min').click(); // $('#double_your_btc_2x').click(); // multiplier = 2; // } } currentMsg = ''; bChange = function(next) { var cmsg = { lose: $('#double_your_btc_bet_lose').html(), win: $('#double_your_btc_bet_win').html() }; cmsg = JSON.stringify(cmsg); if (currentMsg !== cmsg) { $('#balance_b').html($('#balance').html()); $('#roundwin_b').html((parseFloat($('#balance').html()) - initialBalance).toFixed(8)); $('#current_bet_b').html($('#double_your_btc_stake').val()); $('#time_b').html((Math.round(((new Date().getTime()) - startTime) / 1000) / 60 / 60).toFixed(2) + ' h'); currentMsg = cmsg; next(); } setTimeout(function() { setTimeout(function() { bChange(next); }, bconfig.wait) }, 50); }; bChange(rollDice);