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. setTimeout(function() { var buy = CookieCheat.miscVars.objectsOrder[0].id; if (Game.UpgradesById[buy] != "undefined") {Game.UpgradesById[buy].buy(); }if (Game.ObjectsById[buy] != "undefined") {Game.ObjectsById[buy].buy(); } }, 500);
  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 buyUpgrades() {
  115. for (var i = 0; i < Game.UpgradesById.length; i++) {
  116. 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)) {
  117. continue;
  118. } else {
  119. if (Game.UpgradesById[i].unlocked === 1) {
  120. if(Game.cookies >= Game.UpgradesById[i].basePrice) {
  121. Game.UpgradesById[i].buy();
  122. }
  123. }
  124. }
  125. }
  126. }
  127.  
  128. //Lets bind some keys!!!
  129. //Buys one of specified building
  130. Mousetrap.bind('shift+1', function() { Game.ObjectsById[Game.ObjectsById.length - 11].buy(); }); //Cursor
  131. Mousetrap.bind('shift+2', function() { Game.ObjectsById[Game.ObjectsById.length - 10].buy(); }); //Grandma
  132. Mousetrap.bind('shift+3', function() { Game.ObjectsById[Game.ObjectsById.length - 9].buy(); }); //Farm
  133. Mousetrap.bind('shift+4', function() { Game.ObjectsById[Game.ObjectsById.length - 8].buy(); }); //Factory
  134. Mousetrap.bind('shift+5', function() { Game.ObjectsById[Game.ObjectsById.length - 7].buy(); }); //Mine
  135. Mousetrap.bind('shift+6', function() { Game.ObjectsById[Game.ObjectsById.length - 6].buy(); }); //Shipment
  136. Mousetrap.bind('shift+7', function() { Game.ObjectsById[Game.ObjectsById.length - 5].buy(); }); //Alchemy Lab
  137. Mousetrap.bind('shift+8', function() { Game.ObjectsById[Game.ObjectsById.length - 4].buy(); }); //Portal
  138. Mousetrap.bind('shift+9', function() { Game.ObjectsById[Game.ObjectsById.length - 3].buy(); }); //Time Machine
  139. Mousetrap.bind('shift+0', function() { Game.ObjectsById[Game.ObjectsById.length - 2].buy(); }); //Antimatter Condenser
  140. Mousetrap.bind('shift+-', function() { Game.ObjectsById[Game.ObjectsById.length - 1].buy(); }); //Prism
  141.  
  142. //Sells one of specified building
  143. Mousetrap.bind('option+1', function() { Game.ObjectsById[Game.ObjectsById.length - 11].sell(); }); //Cursor
  144. Mousetrap.bind('option+2', function() { Game.ObjectsById[Game.ObjectsById.length - 10].sell(); }); //Grandma
  145. Mousetrap.bind('option+3', function() { Game.ObjectsById[Game.ObjectsById.length - 9].sell(); }); //Farm
  146. Mousetrap.bind('option+4', function() { Game.ObjectsById[Game.ObjectsById.length - 8].sell(); }); //Factory
  147. Mousetrap.bind('option+5', function() { Game.ObjectsById[Game.ObjectsById.length - 7].sell(); }); //Mine
  148. Mousetrap.bind('option+6', function() { Game.ObjectsById[Game.ObjectsById.length - 6].sell(); }); //Shipment
  149. Mousetrap.bind('option+7', function() { Game.ObjectsById[Game.ObjectsById.length - 5].sell(); }); //Alchemy Lab
  150. Mousetrap.bind('option+8', function() { Game.ObjectsById[Game.ObjectsById.length - 4].sell(); }); //Portal
  151. Mousetrap.bind('option+9', function() { Game.ObjectsById[Game.ObjectsById.length - 3].sell(); }); //Time Machine
  152. Mousetrap.bind('option+0', function() { Game.ObjectsById[Game.ObjectsById.length - 2].sell(); }); //Antimatter Condenser
  153. Mousetrap.bind('option+-', function() { Game.ObjectsById[Game.ObjectsById.length - 1].sell(); }); //Prism
  154.  
  155. // Awesome textParticle mod, mostly for execution of "Cookie Clicker Cheats v.X.X launched!" message.
  156. Game.textParticlesAdd = function (text, el) {
  157. //pick the first free (or the oldest) particle to replace it
  158. var highest = 0;
  159. var highestI = 0;
  160. for (var i in Game.textParticles) {
  161. if (Game.textParticles[i].life == -1) {
  162. highestI = i;
  163. break;
  164. }
  165. if (Game.textParticles[i].life > highest) {
  166. highest = Game.textParticles[i].life;
  167. highestI = i;
  168. }
  169. }
  170. var i = highestI;
  171. var x = (Math.random() - 0.5) * 40;
  172. var y = 0; //+(Math.random()-0.5)*40;
  173. if (!el) {
  174. var rect = l('game').getBoundingClientRect();
  175. var x = Math.floor((rect.left + rect.right) / 2);
  176. var y = Math.floor(((rect.bottom)) - 60);
  177. x += (Math.random() - 0.5) * 40;
  178. y += 0; //(Math.random()-0.5)*40;
  179. }
  180. var me = Game.textParticles[i];
  181. if (!me.l) me.l = l('particle' + i);
  182. me.life = 0;
  183. me.x = x;
  184. me.y = y - Game.textParticlesY;
  185. if (me.y < 60) {
  186. for (var j = 0; j <= (rect.bottom); j++) {
  187. me.y += (me.y - 60);
  188. }
  189. }
  190. me.text = text;
  191. me.l.innerHTML = text;
  192. me.l.style.left = Math.floor(Game.textParticles[i].x - 200) + 'px';
  193. me.l.style.bottom = Math.floor(-Game.textParticles[i].y) + 'px';
  194. me.l.style.display = 'block';
  195. Game.textParticlesY += 60;
  196. }
  197.  
  198. function autoAction(name, action) {
  199. if (!options.buttons[name]) {
  200. return;
  201. }
  202. if (name == 'bigCookie') {
  203. options.buttons[name].interval = setInterval(action, options.intervalDelay);
  204. } else {
  205. options.buttons[name].interval = setInterval(action, options.longDelay);
  206. }
  207. }
  208.  
  209. function stopAutoAction(name) {
  210. clearInterval(options.buttons[name].interval);
  211. }
  212.  
  213. function toggleAutoAction(name, action) {
  214. if (!options.buttons[name].on) {
  215. autoAction(name, action);
  216. options.buttons[name].on = true;
  217. options.buttons[name].element.className = 'active';
  218. } else {
  219. stopAutoAction(name);
  220. options.buttons[name].on = false;
  221. options.buttons[name].element.className = '';
  222. }
  223. }
  224.  
  225. function addPanel() {
  226. if (document.getElementById(options.panelId)) {
  227. document.getElementById(options.panelId).remove();
  228. }
  229. options.panel = document.createElement("div");
  230. options.panel.id = options.panelId;
  231. document.body.appendChild(options.panel);
  232. }
  233.  
  234. function addButton(name, label, action) {
  235. if (!options.buttons[name]) {
  236. return;
  237. }
  238. options.buttons[name].element = document.createElement('button');
  239. options.buttons[name].element[(typeof document.body.style.WebkitAppearance == "string") ? "innerText" : "innerHTML"] = label;
  240. options.buttons[name].element.addEventListener('click', action);
  241. options.panel.appendChild(options.buttons[name].element);
  242. }
  243.  
  244. function addStyleSheet() {
  245. var stylesClassName = options.panelId + '-styles';
  246. var styles = document.getElementsByClassName(stylesClassName);
  247. if (styles.length <= 0) {
  248. styles = document.createElement('style');
  249. styles.type = 'text/css';
  250. styles.className += ' ' + stylesClassName;
  251. document.body.appendChild(styles);
  252. }
  253.  
  254. 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;}';
  255. styles[(typeof document.body.style.WebkitAppearance == "string") ? "innerText" : "innerHTML"] = css;
  256. }
  257.  
  258. var link = document.createElement('a');
  259. link.setAttribute('href', 'http://orteil.dashnet.org/experiments/cookie/');
  260. link.target = 'blank';
  261. link.appendChild(
  262. document.createTextNode('Cookie Clicker Classic'));
  263. var add = document.getElementsByTagName('div')[2];
  264. add.insertBefore(document.createTextNode('| '), add.lastChild);
  265. add.insertBefore(link, add.lastChild);
  266.  
  267. if (window.location == "http://orteil.dashnet.org/cookieclicker/") {
  268. var linkb = document.createElement('a');
  269. linkb.setAttribute('href', 'beta');
  270. linkb.target = 'blank';
  271. linkb.appendChild(
  272. document.createTextNode('Try the beta!'));
  273. var addb = document.getElementsByTagName('div')[2];
  274. addb.insertBefore(document.createTextNode(' | '), add.lastChild);
  275. addb.insertBefore(linkb, add.lastChild);
  276. }
  277. var del = document.getElementById('links');
  278. del.parentNode.removeChild(del);
  279. return;
  280. })();
  281.  
  282. var seasonalText;
  283. var d = new Date();
  284.  
  285. if ((d.getMonth() == 1-1) && (d.getDate() == 1)) {
  286. seasonalText = "Happy New Year!"
  287. } else if ((d.getMonth() == 2-1) && (d.getDate() == 14)) {
  288. seasonalText = "Happy Valentine's Day!"
  289. } else if ((d.getMonth() == 3-1) && (d.getDate() == 17)) {
  290. seasonalText = "Happy St. Patrick's Day!"
  291. } else if ((d.getMonth() == 4-1) && (d.getDate() == 20)) {
  292. seasonalText = "Happy Easter Sunday!"
  293. } else if ((d.getMonth() == 7-1) && (d.getDate() == 4)) {
  294. seasonalText = "Happy 4th of July!"
  295. } else if ((d.getMonth() == 10-1) && (d.getDate() == 31)) {
  296. seasonalText = "Happy Halloween!"
  297. } else if ((d.getMonth() == 11-1) && (d.getDate() == 27)) {
  298. seasonalText = "Happy Thanksgiving!"
  299. } else if ((d.getMonth() == 12-1) && (d.getDate() == 25)) {
  300. seasonalText = "Merry Christmas!"
  301. }
  302.  
  303. if (typeof (seasonalText) != 'undefined' && seasonalText != null) {
  304. var seasonText = seasonalText;
  305. var br1 = document.createElement('br');
  306. var br2 = document.createElement('br');
  307. var append = document.createElement('div');
  308. append.setAttribute('id', 'seasonalText');
  309. append.setAttribute('class', 'commentsText');
  310. append.setAttribute('style', 'font-size:28px');
  311. append.appendChild(
  312. document.createTextNode(seasonText));
  313. var add = document.getElementById('comments');
  314. add.insertBefore(br1, add.lastChild);
  315. add.insertBefore(br2, add.lastChild);
  316. add.insertBefore(append, add.lastChild);
  317. Game.Popup(seasonalText);
  318. }
  319.  
  320. setInterval(function() {Game.WriteSave()},20000);
  321.  
  322. var script = document.createElement('script');
  323. script.setAttribute('src', 'https://greasyfork.org/scripts/7952-ccc-libraries/code/CCC%20Libraries.js?version=35672');
  324. document.body.appendChild(script);
  325.  
  326. } else {
  327. setTimeout(doSomething, 1000);
  328. }
  329. }