Cookie clicker hack


SUBMITTED BY: CastellSaiyan

DATE: April 14, 2016, 6:01 p.m.

FORMAT: Text only

SIZE: 1.8 kB

HITS: 36036

  1. var interval = 250;
  2. var autoBuy = true;
  3. var autoBuyTxt = "on";
  4. document.addEventListener('keydown', function(event) {
  5. if(event.keyCode == 65) {
  6. autoBuy = !autoBuy;
  7. if(autoBuy) {autoBuyTxt = "on";}else{autoBuyTxt = "off";}
  8. }
  9. });
  10. var cookieBot = setInterval(function() {
  11. if(autoBuy == true) {
  12. Game.ObjectsById[optimalBuilding()].buy();
  13. }
  14. else {
  15. optimalBuilding();
  16. }
  17. }, interval);
  18. function optimalBuilding() {
  19. cpc = Number.MAX_VALUE;
  20. var x = 0;
  21. cps = 0
  22. for(i = Game.ObjectsById.length-1; i >= 0; i--){
  23. var me = Game.ObjectsById[i];
  24. CpSlower = 0;
  25. for(j = Game.ObjectsById.length-1; j >= 0; j--){ CpSlower += Game.ObjectsById[j].cps()*Game.ObjectsById[j].amount; }
  26. me.amount++;
  27. CpSupper=0;
  28. for(j = Game.ObjectsById.length-1; j >= 0; j--){ CpSupper += Game.ObjectsById[j].cps()*Game.ObjectsById[j].amount; }
  29. me.amount--;
  30. var myCpS = (CpSupper - CpSlower)*Game.globalCpsMult;
  31. var cpc2 = me.price *(Game.cookiesPs + myCpS) / myCpS;
  32. if (cpc2 < cpc) {
  33. cpc = cpc2;
  34. x = i;
  35. cps=myCpS
  36. }
  37. }
  38. var time = (Math.round(Game.ObjectsById[x].price) - Game.cookies) / Game.cookiesPs;
  39. time = time < 0 ? 0 : Beautify(time);
  40. var numb = (Math.abs(Game.computedMouseCps / Game.cookiesPs));
  41. numb = numb.toFixed(3);
  42. var txt = "Buying " + Game.ObjectsById[x].name + " for " +
  43. Beautify(Math.round(Game.ObjectsById[x].price)) + " at " + Beautify(Math.round(Game.ObjectsById[x].price / (cps*Game.globalCpsMult))) +
  44. " cookies per CPS!" + "<br>This will take " + time + " seconds without manually clicking." +
  45. "<br>Each click would save you " + numb + " seconds." + "<br>Click A to toggle auto-buy. Auto-buy is currently " + autoBuyTxt;
  46. Game.Ticker = txt;
  47. Game.TickerAge = interval;
  48. return x;
  49. }

comments powered by Disqus