Yet Another Cookie AutoClicker

4/2/2022, 11:41:51 AM

  1. // ==UserScript==
  2. // @name Yet Another Cookie AutoClicker
  3. // @namespace Violentmonkey Scripts
  4. // @match https://orteil.dashnet.org/cookieclicker
  5. // @grant none
  6. // @version 1.0
  7. // @author minus
  8. // @description 4/2/2022, 11:41:51 AM
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. /// CONSTANTS
  13.  
  14. const sectionLeft = document.getElementById("sectionLeft");
  15.  
  16. const buttonStateText = {
  17. false: "OFF",
  18. true: "ON"
  19. }
  20.  
  21. const buttonCSS = "position: absolute; z-index: 999;";
  22.  
  23. // Copy of the Game.ClickCookie function, just without the things following mouse cursor (it's annoying)
  24. function AutoClickCookie(e,amount) {
  25. var now = Date.now();
  26. if (e) e.preventDefault();
  27. if (Game.OnAscend || Game.AscendTimer>0 || Game.T<3 || now-Game.lastClick<1000/((e?e.detail:1)===0?3:50)) {}
  28. else {
  29. if (now-Game.lastClick<(1000/15)) {
  30. Game.autoclickerDetected+=Game.fps;
  31. if (Game.autoclickerDetected>=Game.fps*5) Game.Win('Uncanny clicker');
  32. }
  33. Game.loseShimmeringVeil('click');
  34. var amount=amount?amount:Game.computedMouseCps;
  35. Game.Earn(amount);
  36. Game.handmadeCookies+=amount;
  37. var px = (sectionLeft.offsetWidth/2);
  38. var py = (sectionLeft.offsetHeight/ 2.25)
  39. if (Game.prefs.particles)
  40. {
  41. Game.particleAdd();
  42. Game.particleAdd(px,py,Math.random()*4-2,Math.random()*-2-2,Math.random()*0.5+0.75,1,2);
  43. }
  44. if (Game.prefs.numbers) Game.particleAdd(px+Math.random()*8-4,py-8+Math.random()*8-4,0,-2,1,4,2,'','+'+Beautify(amount,1));
  45. Game.runModHook('click');
  46. Game.playCookieClickSound();
  47. Game.cookieClicks++;
  48. if (Game.clicksThisSession==0) PlayCue('preplay');
  49. Game.clicksThisSession++;
  50. Game.lastClick=now;
  51. }
  52. Game.Click=0;
  53. }
  54.  
  55. /// END CONSTANTS
  56.  
  57. /// AUTOCLICK
  58.  
  59. var delay = 0;
  60. var doLoop = false;
  61.  
  62. // Autoclick function
  63. function clickLoop(){
  64. AutoClickCookie(null, null);
  65. if(doLoop)
  66. setTimeout(clickLoop, delay);
  67. }
  68.  
  69. function shimmerLoop() {
  70. Game.shimmers.forEach(shimmer => {shimmer.l.click();});
  71. if(doLoop)
  72. setTimeout(shimmerLoop, 50);
  73. }
  74.  
  75. /// END AUTOCLICK
  76.  
  77. /// BUTTON
  78.  
  79. var autoClickButton = document.createElement("button");
  80. autoClickButton.innerText = "Autoclicker: " + buttonStateText[doLoop];
  81. autoClickButton.setAttribute("style", buttonCSS);
  82.  
  83. autoClickButton.onclick = function(){
  84. doLoop = !doLoop;
  85. autoClickButton.innerText = "Autoclicker: " + buttonStateText[doLoop];
  86. clickLoop();
  87. shimmerLoop();
  88. }
  89.  
  90. sectionLeft.appendChild(autoClickButton);
  91.  
  92. /// END BUTTON

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址