Cookie Clicker Cheats

Enable/Disable different cheats/hacks for Cookie Clicker

当前为 2015-04-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Cookie Clicker Cheats
  3. // @namespace https://greasyfork.org/scripts/7921-cookie-clicker-cheats/code/Cookie%20Clicker%20Cheats.user.js
  4. // @description Enable/Disable different cheats/hacks for Cookie Clicker
  5. // @include http://orteil.dashnet.org/cookieclicker/
  6. // @include orteil.dashnet.org/cookieclicker/
  7. // @require https://greasyfork.org/scripts/7922-ccc-css/code/CCC%20CSS.user.js
  8. // @require https://greasyfork.org/scripts/7927-mousetrap/code/Mousetrap.user.js
  9. // @icon http://images2.wikia.nocookie.net/__cb20130827014914/cookieclicker/images/5/5a/PerfectCookie.png
  10. // @grant none
  11. // @run-at document-end
  12. // @version 2.0
  13. // ==/UserScript==
  14.  
  15. // Main wait loop
  16. setTimeout(doSomething, 1000);
  17.  
  18. function doSomething() {
  19. var element = document.getElementById('particle0');
  20. if (typeof (element) != 'undefined' && element != null) {
  21.  
  22. //Game particles have loaded, FIRE AWAY!
  23. (function () {
  24. var options = {
  25. panelId: 'cookie-cheater',
  26. intervalDelay: 1,
  27. longDelay: 250,
  28. buttons: {
  29. 'bigCookie': {
  30. label: 'Autoclick Big Cookie',
  31. action: function () {
  32. toggleAutoAction('bigCookie', function () {
  33. Game.ClickCookie();
  34. })
  35. }
  36. },
  37. 'spawnGoldenCookie': {
  38. label: 'Spawn a Golden Cookie',
  39. action: function () {
  40. Game.goldenCookie.life = 0;
  41. Game.goldenCookie.time = Game.goldenCookie.minTime;
  42. Game.goldenCookie.spawn();
  43. }
  44. },
  45. 'autoGoldenCookie': {
  46. label: 'Autospawnclick GCs',
  47. action: function () {
  48. toggleAutoAction('autoGoldenCookie', function () {
  49. if (Game.frenzy <= 0) {
  50. Game.goldenCookie.time = Game.goldenCookie.minTime;
  51. Game.goldenCookie.spawn();
  52. }
  53. if (Game.goldenCookie.last == "clot" || Game.goldenCookie.last == "ruin cookies") {
  54. if (Game.elderWrath > 0) {
  55. Game.goldenCookie.last = "blood frenzy"
  56. } else {
  57. Game.goldenCookie.last = "frenzy"
  58. }
  59. Game.frenzy = 1
  60. }
  61. if (Game.frenzy > 0) {
  62. Game.goldenCookie.toDie = 1
  63. }
  64. if (Game.goldenCookie.life >= 0 && (Game.frenzy <= 0 || Game.frenzyPower < 2 || Game.goldenCookie.chain > 0)) {
  65. Game.goldenCookie.click();
  66. }
  67. })
  68. }
  69. },
  70. 'autoBuyUpgrades': {
  71. label: 'Autobuy Upgrades',
  72. action: function () {
  73. toggleAutoAction('autoBuyUpgrades', function () {
  74. buyUpgrades();
  75. })
  76. }
  77. },
  78. 'optimalBuying': {
  79. label: 'Optimal Buying',
  80. action: function () {
  81. toggleAutoAction('optimalBuying', function () {
  82. OptiBuy();
  83. })
  84. }
  85. },
  86. 'fuckThemWrinklers': {
  87. label: 'Slaughter Wrinklers',
  88. action: function () {
  89. toggleAutoAction('fuckThemWrinklers', function () {
  90. setTimeout(function() { for (var i in Game.wrinklers) { var me=Game.wrinklers[i]; if (me.phase==2) { me.hurt=1; me.hp--; var x=me.x+(Math.sin(me.r*Math.PI/180)*100); var y=me.y+(Math.cos(me.r*Math.PI/180)*100); for (var ii=0;ii<4;ii++) { Game.particleAdd(x+Math.random()*50-25,y+Math.random()*50-25,Math.random()*4-2,Math.random()*-2-2,1,1,2,'wrinklerBits.png'); } } } }, 200);
  91. })
  92. }
  93. },
  94. 'catchThemWonderdeer': {
  95. label: 'Capture the Deer',
  96. action: function () {
  97. toggleAutoAction('catchThemWonderdeer', function () {
  98. setTimeout(function(){if (Game.seasonPopup.life > 0) {Game.seasonPopup.click()}},Math.floor(((Math.random()*7)+3)*2500));
  99. })
  100. }
  101. },
  102. }
  103. };
  104.  
  105. addStyleSheet();
  106. addPanel();
  107. for (var name in options.buttons) {
  108. if (!options.buttons[name]) {
  109. return;
  110. }
  111. addButton(name, options.buttons[name].label, options.buttons[name].action);
  112. }
  113.  
  114. function OptiBuy() {
  115. setTimeout(function() {
  116. var buy = CookieCheat.miscVars.objectsOrder[0].id
  117. if (Game.UpgradesById[buy] != "undefined") {
  118. Game.UpgradesById[buy].buy()
  119. } else if (Game.ObjectsById[buy] != "undefined") {
  120. Game.ObjectsById[buy].buy()
  121. }
  122. }, 500);
  123. }
  124.  
  125. function buyUpgrades() {
  126. for (var i = 0; i < Game.UpgradesById.length; i++) {
  127. if ((i > 63 && i < 75) || i === 79 || (i > 82 && i < 86) || i === 91 || i === 124 || (i > 140 && i < 143) || i === 167 || (i > 181 && i < 186)) {
  128. continue;
  129. } else {
  130. if (Game.UpgradesById[i].unlocked === 1) {
  131. if(Game.cookies >= Game.UpgradesById[i].basePrice) {
  132. Game.UpgradesById[i].buy();
  133. }
  134. }
  135. }
  136. }
  137. }
  138.  
  139. //Lets bind some keys!!!
  140. //Buys one of specified building
  141. Mousetrap.bind('shift+1', function() { Game.ObjectsById[Game.ObjectsById.length - 11].buy(); }); //Cursor
  142. Mousetrap.bind('shift+2', function() { Game.ObjectsById[Game.ObjectsById.length - 10].buy(); }); //Grandma
  143. Mousetrap.bind('shift+3', function() { Game.ObjectsById[Game.ObjectsById.length - 9].buy(); }); //Farm
  144. Mousetrap.bind('shift+4', function() { Game.ObjectsById[Game.ObjectsById.length - 8].buy(); }); //Factory
  145. Mousetrap.bind('shift+5', function() { Game.ObjectsById[Game.ObjectsById.length - 7].buy(); }); //Mine
  146. Mousetrap.bind('shift+6', function() { Game.ObjectsById[Game.ObjectsById.length - 6].buy(); }); //Shipment
  147. Mousetrap.bind('shift+7', function() { Game.ObjectsById[Game.ObjectsById.length - 5].buy(); }); //Alchemy Lab
  148. Mousetrap.bind('shift+8', function() { Game.ObjectsById[Game.ObjectsById.length - 4].buy(); }); //Portal
  149. Mousetrap.bind('shift+9', function() { Game.ObjectsById[Game.ObjectsById.length - 3].buy(); }); //Time Machine
  150. Mousetrap.bind('shift+0', function() { Game.ObjectsById[Game.ObjectsById.length - 2].buy(); }); //Antimatter Condenser
  151. Mousetrap.bind('shift+-', function() { Game.ObjectsById[Game.ObjectsById.length - 1].buy(); }); //Prism
  152.  
  153. //Sells one of specified building
  154. Mousetrap.bind('option+1', function() { Game.ObjectsById[Game.ObjectsById.length - 11].sell(); }); //Cursor
  155. Mousetrap.bind('option+2', function() { Game.ObjectsById[Game.ObjectsById.length - 10].sell(); }); //Grandma
  156. Mousetrap.bind('option+3', function() { Game.ObjectsById[Game.ObjectsById.length - 9].sell(); }); //Farm
  157. Mousetrap.bind('option+4', function() { Game.ObjectsById[Game.ObjectsById.length - 8].sell(); }); //Factory
  158. Mousetrap.bind('option+5', function() { Game.ObjectsById[Game.ObjectsById.length - 7].sell(); }); //Mine
  159. Mousetrap.bind('option+6', function() { Game.ObjectsById[Game.ObjectsById.length - 6].sell(); }); //Shipment
  160. Mousetrap.bind('option+7', function() { Game.ObjectsById[Game.ObjectsById.length - 5].sell(); }); //Alchemy Lab
  161. Mousetrap.bind('option+8', function() { Game.ObjectsById[Game.ObjectsById.length - 4].sell(); }); //Portal
  162. Mousetrap.bind('option+9', function() { Game.ObjectsById[Game.ObjectsById.length - 3].sell(); }); //Time Machine
  163. Mousetrap.bind('option+0', function() { Game.ObjectsById[Game.ObjectsById.length - 2].sell(); }); //Antimatter Condenser
  164. Mousetrap.bind('option+-', function() { Game.ObjectsById[Game.ObjectsById.length - 1].sell(); }); //Prism
  165.  
  166. // Awesome textParticle mod, mostly for execution of "Cookie Clicker Cheats v.X.X launched!" message.
  167. Game.textParticlesAdd = function (text, el) {
  168. //pick the first free (or the oldest) particle to replace it
  169. var highest = 0;
  170. var highestI = 0;
  171. for (var i in Game.textParticles) {
  172. if (Game.textParticles[i].life == -1) {
  173. highestI = i;
  174. break;
  175. }
  176. if (Game.textParticles[i].life > highest) {
  177. highest = Game.textParticles[i].life;
  178. highestI = i;
  179. }
  180. }
  181. var i = highestI;
  182. var x = (Math.random() - 0.5) * 40;
  183. var y = 0; //+(Math.random()-0.5)*40;
  184. if (!el) {
  185. var rect = l('game').getBoundingClientRect();
  186. var x = Math.floor((rect.left + rect.right) / 2);
  187. var y = Math.floor(((rect.bottom)) - 60);
  188. x += (Math.random() - 0.5) * 40;
  189. y += 0; //(Math.random()-0.5)*40;
  190. }
  191. var me = Game.textParticles[i];
  192. if (!me.l) me.l = l('particle' + i);
  193. me.life = 0;
  194. me.x = x;
  195. me.y = y - Game.textParticlesY;
  196. if (me.y < 60) {
  197. for (var j = 0; j <= (rect.bottom); j++) {
  198. me.y += (me.y - 60);
  199. }
  200. }
  201. me.text = text;
  202. me.l.innerHTML = text;
  203. me.l.style.left = Math.floor(Game.textParticles[i].x - 200) + 'px';
  204. me.l.style.bottom = Math.floor(-Game.textParticles[i].y) + 'px';
  205. me.l.style.display = 'block';
  206. Game.textParticlesY += 60;
  207. }
  208.  
  209. function autoAction(name, action) {
  210. if (!options.buttons[name]) {
  211. return;
  212. }
  213. if (name == 'bigCookie') {
  214. options.buttons[name].interval = setInterval(action, options.intervalDelay);
  215. } else {
  216. options.buttons[name].interval = setInterval(action, options.longDelay);
  217. }
  218. }
  219.  
  220. function stopAutoAction(name) {
  221. clearInterval(options.buttons[name].interval);
  222. }
  223.  
  224. function toggleAutoAction(name, action) {
  225. if (!options.buttons[name].on) {
  226. autoAction(name, action);
  227. options.buttons[name].on = true;
  228. options.buttons[name].element.className = 'active';
  229. } else {
  230. stopAutoAction(name);
  231. options.buttons[name].on = false;
  232. options.buttons[name].element.className = '';
  233. }
  234. }
  235.  
  236. function addPanel() {
  237. if (document.getElementById(options.panelId)) {
  238. document.getElementById(options.panelId).remove();
  239. }
  240. options.panel = document.createElement("div");
  241. options.panel.id = options.panelId;
  242. document.body.appendChild(options.panel);
  243. }
  244.  
  245. function addButton(name, label, action) {
  246. if (!options.buttons[name]) {
  247. return;
  248. }
  249. options.buttons[name].element = document.createElement('button');
  250. options.buttons[name].element[(typeof document.body.style.WebkitAppearance == "string") ? "innerText" : "innerHTML"] = label;
  251. options.buttons[name].element.addEventListener('click', action);
  252. options.panel.appendChild(options.buttons[name].element);
  253. }
  254.  
  255. function addStyleSheet() {
  256. var stylesClassName = options.panelId + '-styles';
  257. var styles = document.getElementsByClassName(stylesClassName);
  258. if (styles.length <= 0) {
  259. styles = document.createElement('style');
  260. styles.type = 'text/css';
  261. styles.className += ' ' + stylesClassName;
  262. document.body.appendChild(styles);
  263. }
  264.  
  265. var css = '#' + options.panelId + '{position:fixed;top:25px;right:0;padding:5px;z-index:9999;}#' + options.panelId + ' button{margin-left: 5px; font-family:\"Kavoon\"; color:#2ba39f;}#' + options.panelId + ' button.active:after{content:"*";color:#1E7471;}';
  266. styles[(typeof document.body.style.WebkitAppearance == "string") ? "innerText" : "innerHTML"] = css;
  267. }
  268.  
  269. var link = document.createElement('a');
  270. link.setAttribute('href', 'http://orteil.dashnet.org/experiments/cookie/');
  271. link.target = 'blank';
  272. link.appendChild(
  273. document.createTextNode('Cookie Clicker Classic'));
  274. var add = document.getElementsByTagName('div')[2];
  275. add.insertBefore(document.createTextNode('| '), add.lastChild);
  276. add.insertBefore(link, add.lastChild);
  277.  
  278. if (window.location == "http://orteil.dashnet.org/cookieclicker/") {
  279. var linkb = document.createElement('a');
  280. linkb.setAttribute('href', 'beta');
  281. linkb.target = 'blank';
  282. linkb.appendChild(
  283. document.createTextNode('Try the beta!'));
  284. var addb = document.getElementsByTagName('div')[2];
  285. addb.insertBefore(document.createTextNode(' | '), add.lastChild);
  286. addb.insertBefore(linkb, add.lastChild);
  287. }
  288. var del = document.getElementById('links');
  289. del.parentNode.removeChild(del);
  290. return;
  291. })();
  292.  
  293. var seasonalText;
  294. var d = new Date();
  295.  
  296. if ((d.getMonth() == 1-1) && (d.getDate() == 1)) {
  297. seasonalText = "Happy New Year!"
  298. } else if ((d.getMonth() == 2-1) && (d.getDate() == 14)) {
  299. seasonalText = "Happy Valentine's Day!"
  300. } else if ((d.getMonth() == 3-1) && (d.getDate() == 17)) {
  301. seasonalText = "Happy St. Patrick's Day!"
  302. } else if ((d.getMonth() == 4-1) && (d.getDate() == 20)) {
  303. seasonalText = "Happy Easter Sunday!"
  304. } else if ((d.getMonth() == 7-1) && (d.getDate() == 4)) {
  305. seasonalText = "Happy 4th of July!"
  306. } else if ((d.getMonth() == 10-1) && (d.getDate() == 31)) {
  307. seasonalText = "Happy Halloween!"
  308. } else if ((d.getMonth() == 11-1) && (d.getDate() == 27)) {
  309. seasonalText = "Happy Thanksgiving!"
  310. } else if ((d.getMonth() == 12-1) && (d.getDate() == 25)) {
  311. seasonalText = "Merry Christmas!"
  312. }
  313.  
  314. if (typeof (seasonalText) != 'undefined' && seasonalText != null) {
  315. var seasonText = seasonalText;
  316. var br1 = document.createElement('br');
  317. var br2 = document.createElement('br');
  318. var append = document.createElement('div');
  319. append.setAttribute('id', 'seasonalText');
  320. append.setAttribute('class', 'commentsText');
  321. append.setAttribute('style', 'font-size:28px');
  322. append.appendChild(
  323. document.createTextNode(seasonText));
  324. var add = document.getElementById('comments');
  325. add.insertBefore(br1, add.lastChild);
  326. add.insertBefore(br2, add.lastChild);
  327. add.insertBefore(append, add.lastChild);
  328. Game.Popup(seasonalText);
  329. }
  330.  
  331. setInterval(function() {Game.WriteSave()},20000);
  332.  
  333. var script = document.createElement('script');
  334. script.setAttribute('src', 'https://greasyfork.org/scripts/7952-ccc-libraries/code/CCC%20Libraries.js?version=35672');
  335. document.body.appendChild(script);
  336.  
  337. } else {
  338. setTimeout(doSomething, 1000);
  339. }
  340. }