click_script.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. var script_1710385880 = {};
  2. script_1710385880.bet_hi = false;
  3. script_1710385880.working = false;
  4. script_1710385880.series = 0;
  5. script_1710385880.last_number = '';
  6. script_1710385880.state = 0;
  7. script_1710385880.tick_state;
  8. script_1710385880.timer_time = 500; // 0.5 sec
  9. script_1710385880.timerId;
  10. function qi(name){ return document.getElementById(name); }
  11. function simulateMouseClick(el){
  12. //const MouseEvents = ['mousedown', 'focusin'];
  13. const MouseEvents = ['click'];
  14. MouseEvents.forEach(eventType =>
  15. el.dispatchEvent(
  16. new MouseEvent(eventType, { bubbles: true })
  17. )
  18. );
  19. }
  20. script_1710385880.started = function(){
  21. script_1710385880.working = true;
  22. script_1710385880.state = 1;
  23. qi('script_1710385880_btn').classList.add('working');
  24. console.log('started');
  25. };
  26. script_1710385880.stopped = function(){
  27. clearTimeout(script_1710385880.timerId);
  28. qi('script_1710385880_btn').classList.remove('working');
  29. script_1710385880.working = false;
  30. script_1710385880.state = 0;
  31. script_1710385880.series = 0;
  32. script_1710385880.timer_time = 500; // set default
  33. console.log('stopped');
  34. };
  35. // check maybe result already exists
  36. script_1710385880.maybe_result = function(){
  37. var maybe_new_num = qi('multiplier_first_digit').value + qi('multiplier_second_digit').value +
  38. qi('multiplier_third_digit').value + qi('multiplier_fourth_digit').value + qi('multiplier_fifth_digit').value;
  39. if(maybe_new_num !== script_1710385880.last_number){
  40. // got result
  41. script_1710385880.last_number = maybe_new_num;
  42. var maybe_win = ( qi('double_your_btc_bet_win').style.display === 'block' );
  43. var maybe_loose = ( qi('double_your_btc_bet_lose').style.display === 'block' );
  44. if(maybe_win){
  45. var was_min = ( qi('double_your_btc_stake').value !== '0.00000001' );
  46. if(was_min){ script_1710385880.state = 1; return } // click BET AMOUNT = MIN
  47. script_1710385880.state = 3; // go click bet
  48. console.log('win');
  49. }else if(maybe_loose){
  50. console.log('lose');
  51. script_1710385880.state = 2; // click BET AMOUNT = 2x // next go click bet
  52. }else{ script_1710385880.state = 3; } // 1st bet
  53. } // else do nothing -- waiting for result
  54. };
  55. script_1710385880.do_start_stop = function(){
  56. if(script_1710385880.working){ script_1710385880.stopped(); return }
  57. script_1710385880.started();
  58. script_1710385880.tick_state = function(){
  59. var bet_btn = (script_1710385880.bet_hi) ? qi('double_your_btc_bet_hi_button') : qi('double_your_btc_bet_lo_button');
  60. if(script_1710385880.state === 0){
  61. // just stopped
  62. // do nothing
  63. }else if(script_1710385880.state === 1){
  64. // set bet amount 1 satoshi = 0.00000001
  65. simulateMouseClick( qi('double_your_btc_min') );
  66. script_1710385880.state = 3;
  67. script_1710385880.timer_time = 100;
  68. }else if(script_1710385880.state === 2){
  69. // double bet amount
  70. simulateMouseClick( qi('double_your_btc_2x') );
  71. script_1710385880.state = 3;
  72. script_1710385880.timer_time = 100;
  73. }else if(script_1710385880.state === 3){
  74. // click bet lo
  75. simulateMouseClick(bet_btn);
  76. script_1710385880.state = 4;
  77. script_1710385880.timer_time = 1000; // wait 1 sec or more time
  78. }else if(script_1710385880.state === 4){
  79. // wait for bet result - check is result exists and maybe wait more
  80. script_1710385880.timer_time = 200;
  81. script_1710385880.maybe_result();
  82. }
  83. if(script_1710385880.state !== 0){ script_1710385880.timerId = setTimeout(script_1710385880.tick_state, script_1710385880.timer_time); }
  84. };
  85. if(script_1710385880.state !== 0){ script_1710385880.timerId = setTimeout(script_1710385880.tick_state, script_1710385880.timer_time); }
  86. };
  87. script_1710385880.do_bind_scripts = function(){
  88. // add start/stop btn -- blue shadows = not working, green shadows = working
  89. document.head.insertAdjacentHTML('beforeend',`<style>div#script_1710385880_btn{display:block;position:fixed;width:55px;height:55px;top:130px;right:175px;cursor:pointer;z-index:777;border-radius:10px;border:1px solid gray;box-shadow: 5px 5px 5px #0559b3;background-color:#fff;background-repeat:no-repeat;background-position:50% center;background-size:35px 35px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M440.5 88.5l-52 52L415 167c9.4 9.4 9.4 24.6 0 33.9l-17.4 17.4c11.8 26.1 18.4 55.1 18.4 85.6 0 114.9-93.1 208-208 208S0 418.9 0 304 93.1 96 208 96c30.5 0 59.5 6.6 85.6 18.4L311 97c9.4-9.4 24.6-9.4 33.9 0l26.5 26.5 52-52 17.1 17zM500 60h-24c-6.6 0-12 5.4-12 12s5.4 12 12 12h24c6.6 0 12-5.4 12-12s-5.4-12-12-12zM440 0c-6.6 0-12 5.4-12 12v24c0 6.6 5.4 12 12 12s12-5.4 12-12V12c0-6.6-5.4-12-12-12zm33.9 55l17-17c4.7-4.7 4.7-12.3 0-17-4.7-4.7-12.3-4.7-17 0l-17 17c-4.7 4.7-4.7 12.3 0 17 4.8 4.7 12.4 4.7 17 0zm-67.8 0c4.7 4.7 12.3 4.7 17 0 4.7-4.7 4.7-12.3 0-17l-17-17c-4.7-4.7-12.3-4.7-17 0-4.7 4.7-4.7 12.3 0 17l17 17zm67.8 34c-4.7-4.7-12.3-4.7-17 0-4.7 4.7-4.7 12.3 0 17l17 17c4.7 4.7 12.3 4.7 17 0 4.7-4.7 4.7-12.3 0-17l-17-17zM112 272c0-35.3 28.7-64 64-64 8.8 0 16-7.2 16-16s-7.2-16-16-16c-52.9 0-96 43.1-96 96 0 8.8 7.2 16 16 16s16-7.2 16-16z'/%3E%3C/svg%3E");}div#script_1710385880_btn.working{box-shadow: 5px 5px 5px #2de03b}</style>`);
  90. var div = document.createElement('div');
  91. div.id = 'script_1710385880_btn';
  92. div.setAttribute('title', 'Start / Stop');
  93. document.body.appendChild(div);
  94. qi('disable_animation_checkbox').checked = true;
  95. qi('manual_enable_sounds').checked = true;
  96. qi('script_1710385880_btn').addEventListener('click', script_1710385880.do_start_stop);
  97. }