Cookie Clicker Cheats

Enable/Disable different cheats/hacks for Cookie Clicker

当前为 2015-02-24 提交的版本,查看 最新版本

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