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