Advertisement
Guest User

HoodModzV1 Cookie Clicker mod menu 1.0

a guest
Nov 26th, 2015
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* HoodModzV1 Cookie Clicker Menu 1.0 */
  2.  
  3. //variables
  4.  
  5. var CheatButton = document.createElement("div");
  6. var hidden = true;
  7. var oldNode = l("links").firstChild;
  8. var newNode = document.createElement("span");
  9. var t = document.createTextNode("Cheat");
  10.  
  11. var clickerBotC = 0;
  12. var clickerBotG = 0;
  13. var buyBot = 0;
  14. var pledgeBot = 0;
  15. var CAmount = 0;
  16. var HAmount = 0;
  17. var BAmount = 0;
  18. var CClickSpeed = 5;
  19. var GClickSpeed = 5;
  20. var MFix = false;
  21. var HFix = false;
  22. var BFree = false;
  23. var bypass = false;
  24. var goldenChoice = 'any';
  25. var buildingChoice = 'all';
  26. var Flast = 1;
  27. var Fpow = 1;
  28. var SHours = 0;
  29. var MilkLvl = 0;
  30. var displayUpgradeHack = '';
  31. var displayAchievementHack = '';
  32. var ABCps;
  33. var ABName;
  34. var ABPrice;
  35. var ABText = '';
  36. var ABInterval = 250;
  37. var ABCurrentCps;
  38. var ABSelected = 0;
  39. var ABOptimal;
  40. var PTime = 0;
  41. var focused = false;
  42. var intRegex = /^\d+$/;
  43. Game.prefs.antilag = 1;
  44. Game.prefs.autoupdatemenu = 1;
  45. Game.prefs.protection = 1;
  46.  
  47. //draw buttons
  48.  
  49. CheatButton.setAttribute("id", "cheatButton");
  50. CheatButton.setAttribute("class", "button");
  51. CheatButton.setAttribute("onMouseOver", "this.style.right=\"-8px\"");
  52. CheatButton.setAttribute("onMouseOut", "this.style.right=\"-16px\"");
  53. CheatButton.style.padding = "14px 16px 10px 0px";
  54. CheatButton.style.top = "0px";
  55. CheatButton.style.right = "-16px";
  56. CheatButton.appendChild(t);
  57. l("comments").insertBefore(CheatButton, l("logButton"));
  58. l('cheatButton').onclick = function () {
  59.     Game.ShowMenu('cheat');
  60. };
  61. newNode.setAttribute("id", "newNode");
  62. newNode.innerHTML = /*'<a class="option" style="height:16px" id="protection" onclick="Game.Toggle(\'protection\',\'protection\',\'protection:on\',\'protection:off\')">' + (Game.prefs.autoupdatemenu ? 'protection:on' : 'protection:off') + '</a> | */'<a class="option" style="height:16px" id="autoupdatemenu" onclick="Game.Toggle(\'autoupdatemenu\',\'autoupdatemenu\',\'autoupdate:on\',\'autoupdate:off\')">' + (Game.prefs.autoupdatemenu ? 'autoupdate:on' : 'autoupdate:off') + '</a> | <a class="option" style="height:16px" id="antilag" onclick="Game.Toggle(\'antilag\',\'antilag\',\'antilag:on\',\'antilag:off\')">' + (Game.prefs.antilag ? 'antilag:on' : 'antilag:off') + '</a> | <a class="option" style="height:16px" id="autosave" onclick="Game.Toggle(\'autosave\',\'autosave\',\'autosave:on\',\'autosave:off\')">' + (Game.prefs.autosave ? 'autosave:on' : 'autosave:off') + '</a> | ';
  63. l("links").insertBefore(newNode, oldNode);
  64. document.addEventListener('keydown', function (event) {
  65.     if (event.keyCode == 80) {
  66.         if (hidden) {
  67.             l("cheatButton").setAttribute("hidden", "true");
  68.             Game.ShowMenu(Game.onMenu);
  69.             Game.Toggle('autobuy', 'autoBuy', 'Autobuy: ON', 'Autobuy: OFF');
  70.             clearInterval(buyBot);
  71.             BuyBot = 0;
  72.             Game.Toggle('autoclick', 'autoClick', 'AutoClick ON', 'AutoClick OFF');
  73.             clearInterval(clickerBotC);
  74.             clickerBotC = 0;
  75.             Game.Toggle('autogolden', 'autoGolden', 'AutoGolden: ON', 'AutoGolden: OFF');
  76.             clearInterval(clickerBotG);
  77.             clickerBotG = 0;
  78.         } else {
  79.             l("cheatButton").removeAttribute("hidden");
  80.         }
  81.         hidden = !hidden;
  82.     }
  83. });
  84.  
  85. //cheat menu
  86.  
  87. Game.oldUpdateMenu = Game.UpdateMenu;
  88. Game.UpdateMenu = function () {
  89.     var str = '';
  90.     if (Game.onMenu != 'cheat') {
  91.         return Game.oldUpdateMenu();
  92.     }
  93.     if (Game.onMenu !== '') {
  94.         str += '<div style="position:absolute;top:8px;right:8px;cursor:pointer;font-size:16px;" onclick="Game.ShowMenu(Game.onMenu);">X</div>';
  95.     }
  96.     if (Game.onMenu == 'cheat') {
  97.         str += '<div class="section">Cheat</div>' +
  98.             '<div class="subsection">' +
  99.             '<div class="title">Configuration</div>' +
  100.             '<div class="listing"><a class="option" onclick="SaveConfig(0);">Save configuration</a><a class="option" onclick="LoadConfig(0);">Load Configuration</a><a class="option" onclick="SaveConfig(1);">Delete save</a><br></div>' +
  101.             '</form></div>' +
  102.             '<div class="subsection">' +
  103.             '<div class="title">Give cookies</div>' +
  104.             '<form>' +
  105.             '<div class="listing"><b>how many:</b> <input id="CAmount" type="number" name="CAmount" value="' + CAmount + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><input id="MFix" type="checkbox" name="MFix" value="MFix" onfocus="focused = true;" onblur="focused = false;"><b>fixed </b><a class="option" onclick="GetCookies();">Get cookies</a><br></div>' +
  106.             '</form></div>' +
  107.             '<div class="subsection">' +
  108.             '<div class="title">Auto-click big cookie</div>' +
  109.             '<form>' +
  110.             '<div class="listing"><b>interval:</b> <input id="CClickSpeed" type="range" value="' + CClickSpeed + '" min="5" max="1000" name="CClickSpeed" onchange=l("displayCClickSpeed").innerHTML=l("CClickSpeed").value step="5" style="width:250px" onfocus="focused = true;" onblur="focused = false;"> <b><span id="displayCClickSpeed">' + CClickSpeed + '</span>ms</b> ' + Game.WriteButton('autoclick', 'autoClick', 'AutoClick ON', 'AutoClick OFF', 'ClickCookie();') + '<br></div>' +
  111.             '</form></div>' +
  112.             '<div class="subsection">' +
  113.             '<div class="title">Auto-click golden cookies</div>' +
  114.             '<form>' +
  115.             '<div class="listing"><input id="bypass" type="checkbox" name="bypass" value="bypass" onfocus="focused = true;" onblur="focused = false;"><b>bypass time; interval:</b> <input id="GClickSpeed" type="range" value="' + GClickSpeed + '" min="5" max="1000" name="GClickSpeed" onchange=l("displayGClickSpeed").innerHTML=l("GClickSpeed").value step="5" style="width:250px" onfocus="focused = true;" onblur="focused = false;"> <b><span id="displayGClickSpeed">' + GClickSpeed + '</span>ms</b>' + Game.WriteButton('autogolden', 'autoGolden', 'AutoGolden: ON', 'AutoGolden: OFF', 'ClickGolden();') + '<br></div>' +
  116.             '</form></div>' +
  117.             '<div class="subsection">' +
  118.             '<div class="title">Spawn a golden cookie</div>' +
  119.             '<form>' +
  120.             '<div class="listing"><select name="goldenChoice" id="goldenChoice" value="' + goldenChoice + '" onfocus="focused = true;" onblur="focused = false;"><option value="any" id="SelectedChoice_any">Any</option><option value="clot" id="SelectedChoice_clot">Clot</option><option value="multiply cookies" id="SelectedChoice_multiply cookies">Lucky</option><option value="ruin cookies" id="SelectedChoice_ruin cookies">Ruin</option><option value="frenzy" id="SelectedChoice_frenzy">Frenzy</option><option value="blood frenzy" id="SelectedChoice_blood frenzy">Elder Frenzy</option><option value="chain cookie" id="SelectedChoice_chain cookie">Chain Cookie</option><option value="click frenzy" id="SelectedChoice_click frenzy">Click Frenzy</option><option value="blab" id="SelectedChoice_blab">Blab</option></select><a class="option" onclick="SpawnGolden();">Spawn a golden cookie</a><br></div>' +
  121.             '</form></div>' +
  122.             '<div class="subsection">' +
  123.             '<div class="title">Create a frenzy</div>' +
  124.             '<form>' +
  125.             '<div class="listing"><b>Last </b><input id="Flast" type="number" name="Flast" value="' + Flast + '" step="1" Style="width:50px" min="1" onfocus="focused = true;" onblur="focused = false;"><b> seconds; multiply by </b><input id="Fpow" type="number" name="Fpow" value="' + Fpow + '" step="1" Style="width:100px" min="1" onfocus="focused = true;" onblur="focused = false;"><a class="option" onclick="SpawnFrenzy();">Spawn the custom frenzy</a><br></div>' +
  126.             '</form></div>' +
  127.             '<div class="subsection">' +
  128.             '<div class="title">Change the game started value</div>' +
  129.             '<form>' +
  130.             '<div class="listing"><b>Game started </b><input id="SHours" type="number" name="SHours" value="' + SHours + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><b> hours ago </b><a class="option" onclick="SetStartDate();">Set the time</a><br></div>' +
  131.             '</form></div>' +
  132.             '<div class="subsection">' +
  133.             '<div class="title">Hack Heavenly Chips</div>' +
  134.             '<form>' +
  135.             '<div class="listing"><b>Amount of H.C: </b><input id="HAmount" type="number" name="HAmount" value="' + HAmount + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><input id="HFix" type="checkbox" name="HFix" value="HFix" onfocus="focused = true;" onblur="focused = false;"><b>fixed </b><a class="option" onclick="GetHeavenly();">Get Heavenly Chips</a></div>' +
  136.             '</form><br></div>' +
  137.             '<div class="subsection">' +
  138.             '<div class="title">Set Milk level</div>' +
  139.             '<form>' +
  140.             '<div class="listing"><b>set Milk level: </b><input id="MilkLvl" type="number" name="MilkLvl" value="' + MilkLvl + '" step="1" Style="width:100px" min="0" onfocus="focused = true;" onblur="focused = false;"><b> % </b><a class="option" onclick="SetMilk();">Set Milk</a><br></div>' +
  141.             '</form></div>' +
  142.             '<div class="subsection">' +
  143.             '<div class="title">Upgrade Hack!</div>' +
  144.             '<form>' +
  145.             '<div class="listing">' + Game.WriteButton('upgradehack', 'upgradeHack', 'Upgrade Hack!: ON', 'Upgrade Hack: OFF', 'UpgradeHack();SmartUpdateMenu();') + '<a class="option" onclick="AllUpgrades();">Toggle all upgrades</a>' +
  146.             '<br><div id="displayUpgradeHack" style="overflow-y:hidden;">' + displayUpgradeHack + '</div><br></div>' +
  147.             '</form></div>' +
  148.             '<div class="subsection">' +
  149.             '<div class="title">Hack achievements</div>' +
  150.             '<form>' +
  151.             '<div class="listing">' + Game.WriteButton('achievementhack', 'achievementHack', 'Hack achievements: ON', 'Hack achievements: OFF', 'AchievementHack();SmartUpdateMenu();') + '<a class="option" onclick="AllAchievements();">Toggle all achievements</a>' +
  152.             '<br><div id="displayAchievementHack" style="overflow-y:hidden;">' + displayAchievementHack + '</div><br></div>' +
  153.             '</form></div>' +
  154.             '<div class="subsection">' +
  155.             '<div class="title">Autobuy</div>' +
  156.             '<form>' +
  157.             '<div class="listing">' + Game.WriteButton('autobuy', 'autoBuy', 'Autobuy: ON', 'Autobuy: OFF', 'AutoBuy();') +
  158.             '<br><div id="displayAutoBuyText">' + ABText + '</div><br></div>' +
  159.             '</form></div>' +
  160.             '<div class="subsection">' +
  161.             '<div class="title">Hack buildings</div>' +
  162.             '<form>' +
  163.             '<div class="listing"><select name="buildingChoice" id="buildingChoice" value="' + buildingChoice + '" onfocus="focused = true;" onblur="focused = false;">' + SelectBuilding() + '</select><b>Amount of building: </b><input id="BAmount" type="number" name="BAmount" value="' + BAmount + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><input id="BFree" type="checkbox" name="BFree" value="BFree" onfocus="focused = true;" onblur="focused = false;"><b>set price to 0 </b><a class="option" onclick="GetBuilding();">Hack buildings</a><br></div>' +
  164.             '</form></div>' +
  165.             '<div class="subsection">' +
  166.             '<div class="title">Instant research</div>' +
  167.             '<form>' +
  168.             '<div class="listing">' + Game.WriteButton('instantsearch', 'instantSearch', 'Instant search: ON', 'Instant search: OFF', 'InstantSearch();') +
  169.             '</form></div>' +
  170.             '<div class="subsection">' +
  171.             '<div class="title">Custom pledges</div>' +
  172.             '<form>' +
  173.             '<div class="listing"><b>how many minutes:</b> <input id="PTime" type="number" name="PTime" value="' + PTime + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;">' + Game.WriteButton('autobuypledge', 'autoBuyPledge', 'Autobuy Pledge: ON', 'Autobuy Pledge: OFF', 'ABPledge();') + '<a class="option" onclick="CustomPledge();">Custom Pledge</a><br></div>' +
  174.             '</form></div>';
  175.     }
  176.     l("menu").innerHTML = str;
  177.     l("MFix").checked = MFix;
  178.     l("HFix").checked = HFix;
  179.     l("BFree").checked = BFree;
  180.     l("bypass").checked = bypass;
  181.     l("SelectedChoice_" + goldenChoice).setAttribute("selected", "true");
  182.     l("SelectedChoice_" + buildingChoice).setAttribute("selected", "true");
  183.     if (Game.prefs.upgradehack) {
  184.         UpgradeHack();
  185.     }
  186.     if (Game.prefs.achievementhack) {
  187.         AchievementHack();
  188.     }
  189.     if (Game.prefs.autoclick && clickerBotC === 0) {
  190.         ClickCookieFunction();
  191.     }
  192.     if (Game.prefs.autogolden && clickerBotG === 0) {
  193.         ClickGoldenFunction();
  194.     }
  195.     if (Game.prefs.autobuy && buyBot === 0) {
  196.         AutoBuyFunction();
  197.     }
  198. };
  199.  
  200. //modified original code
  201.  
  202. Game.Draw = function () {
  203.     Game.DrawBackground();
  204.     var unit=(Math.round(Game.cookiesd)==1?' cookie':' cookies');
  205.     if (Math.round(Game.cookiesd).toString().length>11 && !Game.mobile) unit='<br>cookies';
  206.     var str=Beautify(Math.round(Game.cookiesd))+unit+'<div style="font-size:50%;">per second : '+Beautify(Game.cookiesPs,1)+'</div>';//display cookie amount
  207.     l('cookies').innerHTML=str;
  208.     l('compactCookies').innerHTML=str;
  209.     Game.TickerDraw();
  210.     for (var i in Game.Objects)
  211.     {
  212.         var me=Game.Objects[i];
  213.         if (Game.cookies>=me.price) l('product'+me.id).className='product enabled'; else l('product'+me.id).className='product disabled';
  214.         if (l('rowInfo'+me.id) && Game.T%5==0) l('rowInfoContent'+me.id).innerHTML='&bull; '+me.amount+' '+(me.amount==1?me.single:me.plural)+'<br>&bull; producing '+Beautify(me.storedTotalCps,1)+' '+(me.storedTotalCps==1?'cookie':'cookies')+' per second<br>&bull; total : '+Beautify(me.totalCookies)+' '+(Math.floor(me.totalCookies)==1?'cookie':'cookies')+' '+me.actionName;
  215.     }
  216.     for (var i in Game.UpgradesInStore)
  217.     {
  218.         var me=Game.UpgradesInStore[i];
  219.         if (Game.cookies>=me.basePrice) l('upgrade'+i).className='crate upgrade enabled'; else l('upgrade'+i).className='crate upgrade disabled';
  220.     }
  221.     if (Math.floor(Game.T % Game.fps / 2) === 0 && Game.onMenu != 'cheat' && Game.prefs.autoupdatemenu) Game.UpdateMenu();
  222.     else if (Math.floor(Game.T % Game.fps / 2) === 0 && Game.onMenu == 'cheat' && !focused && Game.prefs.autoupdatemenu) SmartUpdateMenu();
  223.     Game.cookieNumbersUpdate();
  224.     Game.particlesUpdate();
  225.     Game.drawT++;
  226. };
  227.  
  228. Game.goldenCookie.choose = function () {
  229.     if (goldenChoice == 'any') {
  230.         var list=[];
  231.         if (Game.goldenCookie.wrath>0) list.push('clot','multiply cookies','ruin cookies');
  232.         else list.push('frenzy','multiply cookies');
  233.         if (Game.goldenCookie.wrath>0 && Math.random()<0.3) list.push('blood frenzy','chain cookie');
  234.         else if (Math.random()<0.01 && Game.cookiesEarned>=100000) list.push('chain cookie');
  235.         if (Math.random()<0.1) list.push('click frenzy');
  236.         if (Game.goldenCookie.last!='' && Math.random()<0.8 && list.indexOf(Game.goldenCookie.last)!=-1) list.splice(list.indexOf(Game.goldenCookie.last),1);
  237.         if (Math.random()<0.0001) list.push('blab');
  238.         var choice=choose(list);
  239.         return choice;
  240.     } else if (goldenChoice != 'any') {
  241.         return goldenChoice;
  242.     }
  243. };
  244.  
  245. Game.Loop = function () {
  246.     Game.catchupLogic = 0;
  247.     Game.Logic();
  248.     Game.catchupLogic = 1;
  249.     Game.accumulatedDelay += ((new Date().getTime() - Game.time) - 1000 / Game.fps);
  250.     Game.accumulatedDelay = Math.min(Game.accumulatedDelay, 1000 * 5);
  251.     Game.time = new Date().getTime();
  252.     while (Game.accumulatedDelay > 0) {
  253.         if (clickerBotG !== 0 && Game.prefs.antilag && Game.accumulatedDelay > 500) {
  254.             Game.Toggle('autogolden', 'autoGolden', 'AutoGolden: ON', 'AutoGolden: OFF');
  255.             clearInterval(clickerBotG);
  256.             clickerBotG = 0;
  257.         }
  258.         if (clickerBotC !== 0 && Game.prefs.antilag && Game.accumulatedDelay > 500) {
  259.             Game.Toggle('autoclick', 'autoClick', 'AutoClick ON', 'AutoClick OFF');
  260.             clearInterval(clickerBotC);
  261.             clickerBotC = 0;
  262.         }
  263.         if (buyBot !== 0 && Game.prefs.antilag && Game.accumulatedDelay > 500) {
  264.             Game.Toggle('autobuy', 'autoBuy', 'Auto_Buy: ON', 'Auto_Buy: OFF');
  265.             clearInterval(buyBot);
  266.             ABText = '';
  267.             BuyBot = 0;
  268.         }
  269.         Game.Logic();
  270.         Game.accumulatedDelay -= 1000 / Game.fps;
  271.     }
  272.     Game.catchupLogic = 0;
  273.     Game.Draw();
  274.     setTimeout(Game.Loop, 1000 / Game.fps);
  275. };
  276.  
  277. Game.Win = function (what) {
  278.     if (typeof what === 'string') {
  279.         if (Game.Achievements[what]) {
  280.             if (Game.Achievements[what].won === 0) {
  281.                 Game.Achievements[what].won = 1;
  282.                 Game.Popup('Achievement unlocked :<br>' + Game.Achievements[what].name + '<br> ');
  283.                 if (Game.Achievements[what].hide != 3) {
  284.                     Game.AchievementsOwned++;
  285.                 }
  286.                 Game.recalculateGains = 1;
  287.                 if (displayAchievementHack !== '') {
  288.                     AchievementHack();
  289.                 }
  290.             }
  291.         }
  292.     } else {
  293.         for (var i in what) {
  294.             Game.Win(what[i]);
  295.         }
  296.     }
  297. };
  298.  
  299. //functions
  300.  
  301. function SmartUpdateMenu() {
  302.     if (intRegex.test(parseInt(l("CAmount").value, 10)) || !Game.prefs.protection) {
  303.         CAmount = parseInt(l("CAmount").value, 10);
  304.     }
  305.     if (intRegex.test(parseInt(l("HAmount").value, 10)) || !Game.prefs.protection) {
  306.         HAmount = parseInt(l("HAmount").value, 10);
  307.     }
  308.     if (intRegex.test(parseInt(l("BAmount").value, 10)) || !Game.prefs.protection) {
  309.         BAmount = parseInt(l("BAmount").value, 10);
  310.     }
  311.     if (intRegex.test(parseInt(l("PTime").value, 10)) || !Game.prefs.protection) {
  312.         PTime = parseInt(l("PTime").value, 10);
  313.     }
  314.     if (intRegex.test(parseInt(l("Fpow").value, 10)) || !Game.prefs.protection) {
  315.         Fpow = parseInt(l("Fpow").value, 10);
  316.     }
  317.     if (intRegex.test(parseInt(l("Flast").value, 10)) || !Game.prefs.protection) {
  318.         Flast = parseInt(l("Flast").value, 10);
  319.     }
  320.     if (intRegex.test(parseInt(l("SHours").value, 10)) || !Game.prefs.protection) {
  321.         SHours = parseInt(l("SHours").value, 10);
  322.     }
  323.     if (intRegex.test(parseInt(l("CClickSpeed").value, 10)) || !Game.prefs.protection) {
  324.         CClickSpeed = parseInt(l("CClickSpeed").value, 10);
  325.     }
  326.     if (intRegex.test(parseInt(l("GClickSpeed").value, 10)) || !Game.prefs.protection) {
  327.         GClickSpeed = parseInt(l("GClickSpeed").value, 10);
  328.     }
  329.     if (intRegex.test(parseInt(l("MilkLvl").value, 10)) || !Game.prefs.protection) {
  330.         MilkLvl = parseInt(l("MilkLvl").value, 10);
  331.     }
  332.     MFix = l("MFix").checked;
  333.     HFix = l("HFix").checked;
  334.     BFree = l("BFree").checked;
  335.     bypass = l("bypass").checked;
  336.     goldenChoice = l("goldenChoice").value;
  337.     buildingChoice = l("buildingChoice").value;
  338.     Game.UpdateMenu();
  339. }
  340.  
  341. function SaveConfig(remove) {
  342.     SmartUpdateMenu();
  343.     Game.WriteSave();
  344.     if (!remove) {
  345.         var str = '';
  346.         str += (Game.prefs.antilag ? '1' : '0') + (Game.prefs.autoupdatemenu ? '1' : '0') + (Game.prefs.autoclick ? '1' : '0') + (Game.prefs.autogolden ? '1' : '0') + (Game.prefs.upgradehack ? '1' : '0') + (Game.prefs.achievementhack ? '1' : '0') + (Game.prefs.autobuy ? '1' : '0') + (Game.prefs.instantsearch ? '1' : '0') + (Game.prefs.autobuypledge ? '1' : '0') + (MFix ? '1' : '0') + (HFix ? '1' : '0') + (BFree ? '1' : '0') + (bypass ? '1' : '0') +
  347.             '|';
  348.         str += parseInt(Math.floor(CAmount), 10) + ';' + parseInt(Math.floor(BAmount), 10) + ';' + parseInt(Math.floor(HAmount), 10) + ';' + parseInt(Math.floor(PTime), 10) + ';' + parseInt(Math.floor(Fpow), 10) + ';' + parseInt(Math.floor(Flast), 10) + ';' + parseInt(Math.floor(SHours), 10) + ';' + parseInt(Math.floor(CClickSpeed), 10) + ';' + parseInt(Math.floor(GClickSpeed), 10) + ';' + parseInt(Math.floor(MilkLvl), 10) +
  349.             '|';
  350.         str += goldenChoice + ';' + buildingChoice;
  351.         str = utf8_to_b64(str);
  352.         localStorage.purecookieconfig = str;
  353.     } else if (remove) {
  354.         if (localStorage.purecookieconfig) {
  355.             localStorage.removeItem("purecookieconfig");
  356.         }
  357.     }
  358. }
  359.  
  360. function LoadConfig(auto) {
  361.     if (localStorage.purecookieconfig) {
  362.         var str = '';
  363.         str = localStorage.purecookieconfig;
  364.         str = b64_to_utf8(str);
  365.         str = str.split('|');
  366.         spl = str[0].split(''); //prefs
  367.         Game.prefs.antilag = parseInt(spl[0], 10);
  368.         Game.prefs.autoupdatemenu = parseInt(spl[1], 10);
  369.         Game.prefs.autoclick = parseInt(spl[2], 10);
  370.         Game.prefs.autogolden = parseInt(spl[3], 10);
  371.         Game.prefs.upgradehack = parseInt(spl[4], 10);
  372.         Game.prefs.achievementhack = parseInt(spl[5], 10);
  373.         Game.prefs.autobuy = parseInt(spl[6], 10);
  374.         Game.prefs.instantsearch = parseInt(spl[7], 10);
  375.         Game.prefs.autobuypledge = parseInt(spl[8], 10);
  376.         MFix = parseInt(spl[9], 10);
  377.         HFix = parseInt(spl[10], 10);
  378.         BFree = parseInt(spl[11], 10);
  379.         bypass = parseInt(spl[12], 10);
  380.         spl = str[1].split(';');
  381.         CAmount = parseInt(spl[0], 10);
  382.         BAmount = parseInt(spl[1], 10);
  383.         HAmount = parseInt(spl[2], 10);
  384.         PTime = parseInt(spl[3], 10);
  385.         Fpow = parseInt(spl[4], 10);
  386.         Flast = parseInt(spl[5], 10);
  387.         SHours = parseInt(spl[6], 10);
  388.         CClickSpeed = parseInt(spl[7], 10);
  389.         GClickSpeed = parseInt(spl[8], 10);
  390.         MilkLvl = parseInt(spl[9], 10);
  391.         spl = str[2].split(';');
  392.         goldenChoice = spl[0];
  393.         buildingChoice = spl[1];
  394.     } else if (!auto) {
  395.         confirm('you can\'t load a save that don\'t exist silly :)');
  396.     }
  397.     Game.UpdateMenu();
  398. }
  399.  
  400. function GetCookies() {
  401.     SmartUpdateMenu();
  402.     var toMoney = Math.abs(CAmount - Game.cookies);
  403.     if (CAmount < Game.cookies && MFix) {
  404.         Game.Spend(toMoney);
  405.     } else if (CAmount > Game.cookies && MFix) {
  406.         Game.Earn(toMoney);
  407.     } else if (!MFix) {
  408.         Game.Earn(CAmount);
  409.     }
  410. }
  411.  
  412. function ClickCookie() {
  413.     SmartUpdateMenu();
  414.     var choice = Game.prefs.autoclick;
  415.     if (choice && clickerBotC === 0) {
  416.         ClickCookieFunction();
  417.     } else if (!choice) {
  418.         clearInterval(clickerBotC);
  419.         clickerBotC = 0;
  420.     }
  421. }
  422.  
  423. function ClickCookieFunction() {
  424.     clickerBotC = setInterval(function () {
  425.         Game.ClickCookie();
  426.     }, CClickSpeed);
  427. }
  428.  
  429. function ClickGolden() {
  430.     SmartUpdateMenu();
  431.     var choice = Game.prefs.autogolden;
  432.     if (choice) {
  433.         ClickGoldenFunction();
  434.     } else if (!choice) {
  435.         clearInterval(clickerBotG);
  436.         clickerBotG = 0;
  437.     }
  438. }
  439.  
  440. function ClickGoldenFunction() {
  441.     if (bypass && clickerBotG === 0) {
  442.         clickerBotG = setInterval(function () {
  443.             Game.goldenCookie.life = 1;
  444.             Game.goldenCookie.click();
  445.         }, GClickSpeed);
  446.     } else if (!bypass && clickerBotG === 0) {
  447.         clickerBotG = setInterval(function () {
  448.             if (Game.goldenCookie.life > 0) {
  449.                 Game.goldenCookie.click();
  450.             }
  451.         }, 500);
  452.     }
  453. }
  454.  
  455. function SpawnGolden() {
  456.     SmartUpdateMenu();
  457.     Game.goldenCookie.maxTime = Game.goldenCookie.minTime = Game.goldenCookie.life = 0;
  458. }
  459.  
  460. function SpawnFrenzy() {
  461.     SmartUpdateMenu();
  462.     Game.frenzy = Game.fps * Flast;
  463.     Game.frenzyPower = Fpow;
  464.     Game.CalculateGains();
  465.     Game.Popup("Custom Frenzy! Cookie production x" + Fpow + " for " + Flast + " second!");
  466. }
  467.  
  468. function SetStartDate() {
  469.     SmartUpdateMenu();
  470.     date = new Date().getTime();
  471.     date -= SHours * 3600 * 1000;
  472.     Game.startDate = date;
  473. }
  474.  
  475. function GetHeavenly() {
  476.     SmartUpdateMenu();
  477.     var toGive = 0;
  478.     if (!HFix) {
  479.         toGive = HAmount + Game.prestige['Heavenly chips'];
  480.     } else if (HFix) {
  481.         toGive = HAmount;
  482.     }
  483.     Game.cookiesReset = (Math.pow(2 * toGive + 1, 2) - 1) * Math.pow(10, 12) / 8;
  484.     Game.CalculatePrestige();
  485. }
  486.  
  487. function SetMilk() {
  488.     SmartUpdateMenu();
  489.     toGive = MilkLvl * 0.01;
  490.     Game.AchievementsOwned = toGive * 25;
  491.     Game.CalculateGains();
  492. }
  493.  
  494. function UpgradeHack() {
  495.     var list = [];
  496.     var choice = Game.prefs.upgradehack;
  497.     displayUpgradeHack = '';
  498.     for (var i in Game.Upgrades) {
  499.         list.push(Game.Upgrades[i]);
  500.     }
  501.     for (var i in list) {
  502.         var me = list[i];
  503.         displayUpgradeHack += '<div onclick="Game.UpgradesById[' + me.id + '].toggle();UpgradeHack();SmartUpdateMenu();" class="crate upgrade' + (me.bought > 0 ? ' enabled' : '') + '" ' + Game.getTooltip(
  504.             '<div style="min-width:200px;"><div style="float:right;"><span class="price">' + Beautify(Math.round(me.basePrice)) + '</span></div><small>[Upgrade]' + (me.bought > 0 ? ' [Purchased]' : '') + '</small><div class="name">' + me.name + '</div><div class="description">' + me.desc + '</div></div>', 0, 0, 'bottom-right') + ' style="background-position:' + (-me.icon[0] * 48 + 6) + 'px ' + (-me.icon[1] * 48 + 6) + 'px;"></div>';
  505.     }
  506.     focused = true;
  507.     if (!choice) {
  508.         focused = false;
  509.         displayUpgradeHack = '';
  510.     }
  511. }
  512.  
  513. function AchievementHack() {
  514.     var list = [];
  515.     var choice = Game.prefs.achievementhack;
  516.     displayAchievementHack = '';
  517.     for (var i in Game.Achievements) {
  518.         list.push(Game.Achievements[i]);
  519.     }
  520.     for (var i in list) {
  521.         var me = list[i];
  522.         displayAchievementHack += '<div onclick="ToggleAchievement(' + me.id + ');AchievementHack();SmartUpdateMenu();" class="crate achievement' + (me.won > 0 ? ' enabled' : '') + '" ' + Game.getTooltip(
  523.             '<div style="min-width:200px;"><small>[Achievement]' + (me.won == 1 ? ' [Unlocked]' : '') + (me.hide == 3 ? ' [Shadow]' : '') + '</small><div class="name">' + me.name + '</div><div class="description">' + me.desc + '</div></div>', 0, 0, 'bottom-right') + ' style="background-position:' + (-me.icon[0] * 48 + 6) + 'px ' + (-me.icon[1] * 48 + 6) + 'px;"></div>';
  524.     }
  525.     focused = true;
  526.     if (!choice) {
  527.         focused = false;
  528.         displayAchievementHack = '';
  529.     }
  530. }
  531.  
  532. Game.Lose = function (what) {
  533.     if (typeof what === 'string') {
  534.         if (Game.Achievements[what]) {
  535.             if (Game.Achievements[what].won == 1) {
  536.                 Game.Achievements[what].won = 0;
  537.                 Game.Popup('Achievement locked :<br>' + Game.Achievements[what].name + '<br> ');
  538.                 Game.AchievementsOwned--;
  539.                 Game.recalculateGains = 1;
  540.             }
  541.         }
  542.     } else {
  543.         for (var i in what) {
  544.             Game.Lose(what[i]);
  545.         }
  546.     }
  547. };
  548.  
  549. function ToggleAchievement(what) {
  550.     if (typeof what === 'number') {
  551.         var that = Game.AchievementsById[what].name;
  552.         if (Game.Achievements[that]) {
  553.             if (Game.Achievements[that].won === 0) {
  554.                 Game.Win(that);
  555.             } else {
  556.                 Game.Lose(that);
  557.             }
  558.         }
  559.     }
  560. }
  561.  
  562. function DisplayAutobuy() {
  563.     var time = (ABPrice - Game.cookies) / Game.cookiesPs;
  564.     time = time < 0 ? 0 : Beautify(time);
  565.     ABText = "Buying " + ABName + " for " + Beautify(ABPrice) + " at " + Beautify(Math.round(ABPrice / (ABCps * Game.globalCpsMult))) + " cookies per CPS!" + "<br>This will take " + time + " seconds.";
  566.     if (Game.onMenu == 'cheat') {
  567.         l("displayAutoBuyText").innerHTML = ABText;
  568.     }
  569. }
  570.  
  571. function OptimalItem() {
  572.     var cpc = Number.MAX_VALUE;
  573.     var sel;
  574.     for (i = Game.UpgradesInStore.length - 1; i >= 0; i--) {
  575.         var cps1 = 0;
  576.         var x = Game.UpgradesInStore[i].id;
  577.         var me = Game.UpgradesById[x];
  578.         if (x != 64 && x != 74 && x != 84 && x != 85) {
  579.             Game.UpgradesById[x].bought = 1;
  580.             Game.CalculateGains();
  581.             for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
  582.                 cps1 += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
  583.             }
  584.             var cps2 = cps1 * Game.globalCpsMult;
  585.             Game.UpgradesById[x].bought = 0;
  586.             Game.CalculateGains();
  587.             var myCps = cps2 - ABCurrentCps;
  588.             var cpsUpgrade = me.basePrice * (Game.cookiesPs + myCps) / myCps;
  589.             if (cpsUpgrade < cpc && myCps >= 0.1) {
  590.                 cpc = cpsUpgrade;
  591.                 sel = me;
  592.                 ABCps = myCps;
  593.                 ABName = me.name;
  594.                 ABPrice = Math.round(me.basePrice);
  595.             }
  596.         }
  597.     }
  598.     for (i = Game.ObjectsById.length - 1; i >= 0; i--) {
  599.         var cps1 = 0;
  600.         var me = Game.ObjectsById[i];
  601.         me.amount++;
  602.         Game.CalculateGains();
  603.         for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
  604.             cps1 += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
  605.         }
  606.         var cps2 = cps1 * Game.globalCpsMult;
  607.         me.amount--;
  608.         Game.CalculateGains();
  609.         var myCps = cps2 - ABCurrentCps;
  610.         var cpsBuilding = me.price * (Game.cookiesPs + myCps) / myCps;
  611.         if (cpsBuilding < cpc && myCps >= 0.1) {
  612.             cpc = cpsBuilding;
  613.             sel = me;
  614.             ABCps = myCps;
  615.             ABName = me.name;
  616.             ABPrice = Math.round(me.price);
  617.         }
  618.     }
  619.     ABSelected = 1;
  620.     ABOptimal = sel;
  621. }
  622.  
  623. function AutoBuy() {
  624.     ABInterval = 250;
  625.     var choice = Game.prefs.autobuy;
  626.     if (choice && buyBot === 0) {
  627.         AutoBuyFunction();
  628.     } else if (!choice) {
  629.         clearInterval(buyBot);
  630.         BuyBot = 0;
  631.         ABText = '';
  632.         SmartUpdateMenu();
  633.     }
  634. }
  635.  
  636. function AutoBuyFunction() {
  637.     ABCurrentCps = Game.cookiesPs;
  638.     buyBot = setInterval(function () {
  639.         if (Game.cookies >= ABPrice && ABSelected == 1) {
  640.             ABOptimal.buy();
  641.             DisplayAutobuy();
  642.             ABSelected = 0;
  643.         } else if (ABSelected === 0 || ABCurrentCps != Game.cookiesPs) {
  644.             OptimalItem();
  645.             DisplayAutobuy();
  646.         } else if (ABSelected == 1) {
  647.             DisplayAutobuy();
  648.         }
  649.     }, ABInterval);
  650. }
  651.  
  652. function GetBuilding() {
  653.     SmartUpdateMenu();
  654.     if (buildingChoice != 'all') {
  655.         var me = Game.ObjectsById[buildingChoice];
  656.         me.amount = me.bought = BAmount;
  657.         if (BFree) {
  658.             me.basePrice = 0;
  659.             me.refresh();
  660.         }
  661.     } else if (buildingChoice == 'all') {
  662.         for (i = 0; i < Game.Object.length; i++) {
  663.             var me = Game.ObjectsById[i];
  664.             me.amount = me.bought = BAmount;
  665.             if (BFree) {
  666.                 me.basePrice = 0;
  667.                 me.refresh();
  668.             }
  669.         }
  670.     }
  671.     BOUpdate();
  672.     Game.CalculateGains();
  673.     Game.RebuildStore();
  674. }
  675.  
  676. function SelectBuilding() {
  677.     var text;
  678.     for (i = 0; i < Game.Object.length; i++) {
  679.         me = Game.ObjectsById[i];
  680.         text += '<option value="' + i + '" id="SelectedChoice_' + i + '">' + me.name + '</option>';
  681.     }
  682.     return '<option value="all" id="SelectedChoice_all">All</option>' + text;
  683. }
  684.  
  685. function InstantSearch() {
  686.     SmartUpdateMenu();
  687.     var choice = Game.prefs.instantsearch;
  688.     if (choice) {
  689.         Game.researchT = 0;
  690.         Game.baseResearchTime = 0;
  691.     } else if (!choice) {
  692.         Game.baseResearchTime = Game.fps * 60 * 30;
  693.     }
  694. }
  695.  
  696. function CustomPledge() {
  697.     SmartUpdateMenu();
  698.     Game.pledgeT = Game.fps * 60 * PTime;
  699.     Game.Lock('Elder Pledge');
  700.     Game.elderWrath = 0;
  701.     Game.pledges++;
  702. }
  703.  
  704. function ABPledge() {
  705.     SmartUpdateMenu();
  706.     var choice = Game.prefs.autobuypledge;
  707.     var toWait = (Game.pledgeT / Game.fps) * 1000;
  708.     if (choice) {
  709.         pledgeBot = setTimeout(function () {
  710.             Game.UpgradesById[74].buy();
  711.             ABPledge();
  712.         }, toWait);
  713.     }
  714.     if (!choice) {
  715.         clearTimeout(pledgeBot);
  716.         pledgeBot = 0;
  717.     }
  718. }
  719.  
  720. function AllUpgrades() {
  721.     SmartUpdateMenu();
  722.     for (var i in Game.Upgrades) {
  723.         Game.Upgrades[i].toggle();
  724.     }
  725.     Game.CalculateGains();
  726.     Game.RebuildUpgrades();
  727.     UpgradeHack();
  728. }
  729.  
  730. function AllAchievements() {
  731.     SmartUpdateMenu();
  732.     for (var i in Game.Achievements) {
  733.         ToggleAchievement(Game.Achievements[i].id);
  734.     }
  735.     Game.CalculateGains();
  736.     AchievementHack();
  737. }
  738.  
  739. function BOUpdate() {
  740.     Game.BuildingsOwned = 0;
  741.     for (i = 0; i < Game.Object.length; i++) {
  742.         me = Game.ObjectsById[i];
  743.         Game.BuildingsOwned += me.amount;
  744.         if (me.buyFunction) {
  745.             me.buyFunction();
  746.         }
  747.         if (me.drawFunction) {
  748.             me.drawFunction();
  749.         }
  750.         if (me.amount >= 1 && me.id !== 0) {
  751.             l('row' + me.id).className = 'row enabled';
  752.         }
  753.     }
  754. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement