Cookie Clicker hack

Just a cookie clicker hack.

目前为 2019-12-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Cookie Clicker hack
  3. // @namespace https://greasyfork.org/ru/scripts/392425-cookie-clicker-hack
  4. // @version 1.2.1.1
  5. // @license MIT
  6. // @description Just a cookie clicker hack.
  7. // @author hasha2982
  8. // @match *://orteil.dashnet.org/cookieclicker/*
  9. // @match *://orteil.dashnet.org/cookieclicker/
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // NOTE: Don't works in IE!
  14.  
  15. console.log('[== Starting hack... ==]');
  16.  
  17. var ans = '';
  18. var confirmans = false;
  19. var forCookies = {
  20. iter: 0,
  21. ctr: 0
  22. }
  23.  
  24. const hinfo = {
  25. version: '1.2.1',
  26. changes: 'Added Mouse Wheel mode!'
  27. }
  28.  
  29. var ac = {
  30. sure: false,
  31. click: function() {
  32. document.getElementById('bigCookie').click();
  33. },
  34. timer: null, // used for clearTimeout in ac.termtimer()
  35. termtimer: function() {
  36. if (ac.timer === null) {
  37. alert('false ac.termtimer() call');
  38. console.log(ac);
  39. } else {
  40. clearTimeout(ac.timer);
  41. }
  42. },
  43. warning: false
  44. }
  45.  
  46. var mwheel = {
  47. active: false,
  48. active2: false
  49. }
  50.  
  51. document.onkeydown = function(e){
  52. e = e || window.event;
  53. var key = e.which || e.keyCode;
  54. if(key===72){
  55. hackMenu();
  56. } else if (key === 67) {
  57. ac.termtimer();
  58. }
  59. }; // thx StackOverflow
  60.  
  61. var hmenuText = 'Welcome to hasha2982\'s Cookie Clicker hack v.' + hinfo.version + '!\nPlease select an option below:\n1) Earn free cookies\n2) Spawn golden cookies\n3) Autoclicker (tested on Cookie Clicker v.2.022)\n4) Mouse Wheel mode';
  62.  
  63. function hackMenu() {
  64. // if (event.code = 'KeyH') {
  65. ans = prompt(hmenuText);
  66. if (ans == '1') {
  67. ans = prompt('How many cookies do you want to earn?');
  68. if (ans === "" || ans === null) {
  69. alert('Cancelled.');
  70. } else {
  71. Game.cookies += Number(ans);
  72. Game.cookiesEarned += Number(ans);
  73. }
  74. ///////////////////////////////////////////////////
  75. } else if (ans == '2') {
  76. ans = prompt('How many cookies do you want to spawn?');
  77. if (!(ans === "" || ans === null) && Number(ans) > 0) {
  78. forCookies.iter = Number(ans);
  79. for (; forCookies.ctr < forCookies.iter; forCookies.ctr++) {
  80. var newShimmer=new Game.shimmer("golden");
  81. console.log(`Golden cookie spawned.\nIteration ${forCookies.ctr} is finished.\nIterations remaining: ${forCookies.iter - forCookies.ctr}`);
  82. }
  83. forCookies.iter = 0;
  84. forCookies.ctr = 0;
  85. } else {
  86. alert('Cancelled.');
  87. }
  88. }
  89. ////////////////////////////////////////////////////
  90. else if (ans == '3') {
  91. ans = prompt('Enter delay between clicks in ms. (1000 ms. = 1 s.)\n(press \'c\' to disable autoclicker)');
  92. if (ans === null || ans === "" || ans === '0' || Number(ans) < 1) {
  93. alert('Cancelled.');
  94. } else if (Number(ans) <= 100) {
  95. confirmans = confirm('Delay lower than 100ms. can cause lags.\nAre you sure?');
  96. if (confirmans === true) {
  97. ac.sure = true;
  98. console.log(`ac.sure is set to true\n`); console.log(ac);
  99. }
  100. // if (ac.sure === true) { // here it goes
  101. ac.timer = setInterval(ac.click, Number(ans));
  102. // }
  103. } else {
  104. ac.timer = setInterval(ac.click, Number(ans));
  105. }
  106. }
  107. else if (ans === '4') {
  108. if (mwheel.active === false) {
  109. confirmans = confirm('Mouse wheel mode is disabled.\nIn mouse wheel mode every mouse wheel movement counts as a click on the cookie.\nYou can still use mouse buttons.\nPress \'OK\' to activate mouse wheel mode.\n(sorry for bad English.)');
  110. if (confirmans === true) {
  111. mwheel.active2 = true;
  112. console.log('Mouse wheel mode is activated.');
  113. } else {
  114. alert('Cancelled.');
  115. }
  116. } else if (mwheel.active === true) {
  117. confirmans = confirm('Mouse wheel mode is enabled.\nIn mouse wheel mode every mouse wheel movement counts as a click on the cookie.\nYou can still use mouse buttons.\nPress \'OK\' to deactivate mouse wheel mode.\n(sorry for bad English.)');
  118. if (confirmans === true) {
  119. mwheel.active2 = false;
  120. console.log('Mouse wheel mode is deactivated.');
  121. } else {
  122. alert('Cancelled.');
  123. }
  124. }
  125. if (mwheel.active2 === true) mwheel.active = true;
  126. else if (mwheel.active2 === false) mwheel.active = false;
  127. if (mwheel.active === true) document.onmousewheel = ac.click; // yoink
  128. else if (mwheel.active === false) document.onmousewheel = null; // null is default on orteil.dashnet.org/cookieclicker/
  129. }
  130. else if (ans === null || ans === "") {
  131. console.log('Prevented \'Function not found\' message');
  132. }
  133. else {
  134. alert('Function not found.');
  135. }
  136. // }
  137. }
  138.  
  139. console.log('[== Hack is started. ==]\nVersion: v.' + hinfo.version);