Cookie Clicker Minihack

Adding some basic hack features to Orteil's Cookie Clicker games

当前为 2019-04-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Cookie Clicker Minihack
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.1
  5. // @description Adding some basic hack features to Orteil's Cookie Clicker games
  6. // @author You
  7. // @match *orteil.dashnet.org/cookieclicker/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // yes, I do use ES6, so plz just ignore the "use esversion: 6" warnings
  12. (function() {
  13. 'use strict';
  14. // variables
  15. const config = {
  16. goldenCookies: true, // autoclick all golden cookies
  17. hideNotes: true, // notes/notifications
  18. autoClickSpeed: 20, // false to disable - number to choose clicks per secound
  19. autoshop: 200, // number of each item you want to have before it stops buying automatically
  20. skipGrandma: false // skip buying Grandma in the autoshop function
  21. };
  22.  
  23. // elements to use again, and again, and still again
  24. const shimmers = document.getElementById('shimmers'),
  25. notes = document.getElementById('notes'),
  26. bigCookie = document.getElementById('bigCookie'),
  27. upgrades = document.getElementById('upgrades'),
  28. shop = document.getElementById('products');
  29.  
  30. // autoclick any golden cookies
  31. if (config.goldenCookies) {
  32. setInterval(() => {
  33. let goldenCookies = shimmers.childNodes;
  34. if (goldenCookies.length === 0) return;
  35. for (let i = 0; i < goldenCookies.length; i++) {
  36. goldenCookies[i].click();
  37. }
  38. }, 500);
  39. }
  40.  
  41. // hide annoying notes/notifications located in bottom center
  42. if (config.hideNotes) {
  43. notes.style.display = 'none';
  44. }
  45.  
  46. // autoclick the cookie - limit to x times every secound for preventing overload
  47. if (typeof config.autoClickSpeed === 'number' && config.autoClickSpeed >= 0) {
  48. setInterval(() => {
  49. bigCookie.click();
  50. }, 1000 / config.autoClickSpeed);
  51. }
  52.  
  53. // auto upgrade
  54. setInterval(() => {
  55. const enabledEls = upgrades.childNodes;
  56. for (let i = 0; i < enabledEls.length; i++) {
  57. enabledEls[i].click();
  58. }
  59. }, 100);
  60.  
  61. // autoshop
  62. if (typeof config.autoshop === 'number' && config.autoshop >= 0) {
  63. setInterval(() => {
  64. // will toggle on the "buy" if "sell" is choosen
  65. Game.storeBulkButton(0); // eslint-disable-line
  66. // choose to buy only 1 when clicking items - because this code is based on clicking the elements
  67. Game.storeBulkButton(2); // eslint-disable-line
  68. const items = shop.childNodes;
  69. for (let i = 1; i < items.length; i++) {
  70. const item = items[i];
  71. let amountNode = item.getElementsByClassName('content')[0].childNodes[4];
  72. if (amountNode.innerText*1 < config.autoshop) {
  73. item.click(); // click item if you can afford it, and you don't have the amount you want
  74. }
  75. }
  76. }, 200);
  77. }
  78. })();