1. var startValue = '0.00000001', // Don't lower the decimal point more than 4x of current balance 2. stopPercentage = 0.001, // In %. I wouldn't recommend going past 0.08 3. maxWait = 500, // In milliseconds 4. stopped = false, 5. stopBefore = 3; // In minutes 6. 7. var $loButton = $('#double_your_btc_bet_lo_button'), 8. $hiButton = $('#double_your_btc_bet_hi_button'); 9. 10. function multiply(){ 11. var current = $('#double_your_btc_stake').val(); 12. var multiply = (current * 2).toFixed(8); 13. $('#double_your_btc_stake').val(multiply); 14. } 15. 16. function getRandomWait(){ 17. var wait = Math.floor(Math.random() * maxWait ) + 100; 18. 19. console.log('Waiting for ' + wait + 'ms before next bet.'); 20. 21. return wait ; 22. } 23. 24. function startGame(){ 25. console.log('Game started!'); 26. reset(); 27. $loButton.trigger('click'); 28. } 29. 30. function stopGame(){ 31. console.log('Game will stop soon! Let me finish.'); 32. stopped = true; 33. } 34. 35. function reset(){ 36. $('#double_your_btc_stake').val(startValue); 37. } 38. 39. // quick and dirty hack if you have very little bitcoins like 0.0000001 40. function deexponentize(number){ 41. return number * 1000000; 42. } 43. 44. function iHaveEnoughMoni(){ 45. var balance = deexponentize(parseFloat($('#balance').text())); 46. var current = deexponentize($('#double_your_btc_stake').val()); 47. 48. return ((balance*2)/100) * (current*2) > stopPercentage/100; 49. } 50. 51. function stopBeforeRedirect(){ 52. var minutes = parseInt($('title').text()); 53. 54. if( minutes < stopBefore ) 55. { 56. console.log('Approaching redirect! Stop the game so we don\'t get redirected while loosing.'); 57. stopGame(); 58. 59. return true; 60. } 61. 62. return false; 63. } 64. 65. // Unbind old shit 66. $('#double_your_btc_bet_lose').unbind(); 67. $('#double_your_btc_bet_win').unbind(); 68. 69. // Loser 70. $('#double_your_btc_bet_lose').bind("DOMSubtreeModified",function(event){ 71. if( $(event.currentTarget).is(':contains("lose")') ) 72. { 73. console.log('You LOST! Multiplying your bet and betting again.'); 74. 75. multiply(); 76. 77. setTimeout(function(){ 78. $loButton.trigger('click'); 79. }, getRandomWait()); 80. 81. //$loButton.trigger('click'); 82. } 83. }); 84. 85. // Winner 86. $('#double_your_btc_bet_win').bind("DOMSubtreeModified",function(event){ 87. if( $(event.currentTarget).is(':contains("win")') ) 88. { 89. if( stopBeforeRedirect() ) 90. { 91. return; 92. } 93. 94. if( iHaveEnoughMoni() ) 95. { 96. console.log('You WON! But don\'t be greedy. Restarting!'); 97. 98. reset(); 99. 100. if( stopped ) 101. { 102. stopped = false; 103. return false; 104. } 105. } 106. else 107. { 108. console.log('You WON! Betting again'); 109. } 110. 111. setTimeout(function(){ 112. $loButton.trigger('click'); 113. }, getRandomWait()); 114. } 115. });startgame()