Cookie clicker tools

Cookie clicker tools (visual)

当前为 2017-04-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Cookie clicker tools
  3. // @namespace orteil.dashnet.org
  4. // @version 2.139
  5. // @description Cookie clicker tools (visual)
  6. // @author Anton
  7. // @match http://orteil.dashnet.org/cookieclicker/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var log = [], newLogs = 0;
  14.  
  15. var started = false, t2, t3, tClickFrenzy, oldTitle = '', tLog,
  16. tPriority, tBankAuto, tAscendDetector, isClickingNow = false,
  17. tSeasonSwitcher, tReloadPageOnWrongBuff, tAutoClickInterval = 75,
  18. version = typeof GM_info == 'function' ? GM_info().script.version :
  19. (typeof GM_info == 'object' ? GM_info.script.version : '?'),
  20. logTitle = '<div class="section">Cookie clicker tools ' + version +' is here!</div>';
  21.  
  22. var _history = function() {
  23. var hist = [];
  24. hist.push('2.136 - buyAll function (it is a kind of cheat)');
  25. hist.push('2.128 - santa and dragon upgrades');
  26. hist.push('2.122 - season switcher');
  27. hist.push('2.118 - show season unlocks in "Need to unlock" table');
  28. hist.push('2.114 - option to disable auto clicking');
  29. hist.push('2.113 - info table "Achievements to unlock"');
  30. hist.push('2.112 - info table "Need to unlock"');
  31. hist.push('2.111 - option to buy infernal upgrades');
  32. hist.push('2.109 - kill all wrinklers button');
  33. hist.push('2.107 - click first 15 minutes after ascend');
  34. hist.push('2.101 - remove all bufs on negative multiplier (same as reload page)');
  35. hist.push('2.100 - Info section + ascend detector');
  36. hist.push('2.099 - mouse click upgrades');
  37. hist.push('2.097 - auto bank storage');
  38. hist.push('2.096 - buy objects more than 1');
  39. hist.push('2.091 - priority table refactor');
  40. hist.push('2.090 - buy very cheap items first');
  41. hist.push('2.086 - clear log button');
  42. hist.push('2.084 - buy unknown upgrades if their price is 0.1% of cookie storage');
  43. hist.push('2.083 - mouse upgrades is processed as Upgrades');
  44. hist.push('2.082 - start from scratch');
  45. hist.push('2.079 - hide donate box');
  46. hist.push('2.078 - Kittens now is processed as Upgrades');
  47. return hist;
  48. }
  49.  
  50. var _getKittenPercentByUpgradeName = function(kName) {
  51. if (kName == 'Kitten helpers') return Game.milkProgress*0.1;
  52. if (kName == 'Kitten workers') return Game.milkProgress*0.125;
  53. if (kName == 'Kitten engineers') return Game.milkProgress*0.15;
  54. if (kName == 'Kitten overseers') return Game.milkProgress*0.175;
  55. if (kName == 'Kitten managers') return Game.milkProgress*0.2;
  56. if (kName == 'Kitten accountants') return Game.milkProgress*0.2;
  57. if (kName == 'Kitten specialists') return Game.milkProgress*0.2;
  58. if (kName == 'Kitten experts') return Game.milkProgress*0.2;
  59. if (kName == 'Kitten angels') return Game.milkProgress*0.1;
  60. return 0;
  61. }
  62.  
  63. var _getUpgradeListToUnlock = function() {
  64. var result = [];
  65. for (var x in Game.UnlockAt) {
  66. if (Game.UnlockAt.hasOwnProperty(x) &&
  67. Game.Upgrades.hasOwnProperty(Game.UnlockAt[x].name) &&
  68. Game.Upgrades[Game.UnlockAt[x].name].bought === 0)
  69. {
  70. result.push(Game.UnlockAt[x]);
  71. }
  72. }
  73. var halloweenSeason = ['Skull cookies','Ghost cookies','Bat cookies','Slime cookies','Pumpkin cookies','Eyeball cookies','Spider cookies'];
  74. for (x in halloweenSeason) {
  75. if (halloweenSeason.hasOwnProperty(x) &&
  76. Game.Upgrades[halloweenSeason[x]].bought === 0)
  77. {
  78. result.push({cookies:'',name:halloweenSeason[x],require:'Kill wrinkler',season:'halloween'});
  79. }
  80. }
  81. for (x in Game.easterEggs) {
  82. if (Game.easterEggs.hasOwnProperty(x) &&
  83. Game.Upgrades[Game.easterEggs[x]].bought === 0)
  84. {
  85. result.push({cookies:'',name:Game.easterEggs[x],require:'Find egg',season:'easter'});
  86. }
  87. }
  88. var valentines = ['Pure heart biscuits','Ardent heart biscuits','Sour heart biscuits','Weeping heart biscuits','Golden heart biscuits','Eternal heart biscuits'];
  89. var lastValentineName = '';
  90. for (x in valentines) {
  91. if (valentines.hasOwnProperty(x) &&
  92. Game.Upgrades[valentines[x]].bought === 0)
  93. {
  94. result.push({cookies:'',name:valentines[x],require:lastValentineName,season:'valentines'});
  95. lastValentineName = valentines[x];
  96. }
  97. }
  98. var christmas = ['Christmas tree biscuits','Snowflake biscuits','Snowman biscuits','Holly biscuits','Candy cane biscuits','Bell biscuits','Present biscuits'];
  99. for (x in christmas) {
  100. if (christmas.hasOwnProperty(x) &&
  101. Game.Upgrades[christmas[x]].bought === 0)
  102. {
  103. result.push({cookies:Game.Upgrades[christmas[x]].basePrice,name:christmas[x],require:'Christmas',season:'christmas'});
  104. }
  105. }
  106. return result;
  107. }
  108.  
  109. var options = {
  110. bankStoragePercent: 100,
  111. bankStorageAuto: false,
  112. buyInfernalUpgrades: false,
  113. noClicking: false,
  114. autoSeason: false
  115. };
  116.  
  117. var _store = function(name, value) {
  118. if (typeof(Storage) !== "undefined") localStorage.setItem(name, value);
  119. };
  120.  
  121. var _restore = function(name, asBool) {
  122. if (typeof asBool === 'undefined') asBool = false;
  123. if (typeof(Storage) !== "undefined") {
  124. if (asBool) {
  125. return (localStorage.getItem(name) == 'true' || localStorage.getItem(name) === true);
  126. } else {
  127. return localStorage.getItem(name);
  128. }
  129. }
  130. else return undefined;
  131. };
  132.  
  133. var _getBuffMult = function () {
  134. var buffMult = 1;
  135. for (var buff in Game.buffs) {
  136. if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') {
  137. buffMult = buffMult * Game.buffs[buff].multCpS;
  138. }
  139. }
  140. return buffMult === 0 ? 1 : buffMult;
  141. };
  142.  
  143. var _getNormalCookiesPs = function () {
  144. return Game.cookiesPs > 0 ? Game.cookiesPs / _getBuffMult() : 1;
  145. };
  146.  
  147. var _getMinimalMoney = function () {
  148. return Math.floor(_getNormalCookiesPs() * 42100 * options.bankStoragePercent / 100);
  149. };
  150.  
  151. var _getMoneyCanSpend = function () {
  152. var moneyCanSpend = Game.cookies - _getMinimalMoney();
  153. return moneyCanSpend;
  154. };
  155.  
  156. var _getWrinklerCount = function () {
  157. var wrinklersCount = 0;
  158. for (var i in Game.wrinklers) {
  159. if (Game.wrinklers[i].sucked > 0) {
  160. wrinklersCount++;
  161. }
  162. }
  163. return wrinklersCount;
  164. };
  165.  
  166. var priorityListObj = {}, priorityList = [];
  167. var _createPriorityList = function() {
  168. var moneyCanSpend = _getMoneyCanSpend();
  169. var money = Game.cookies;
  170. var buffMult = _getBuffMult();
  171. priorityList = [];
  172. priorityListObj = {};
  173. // top priority
  174. var topPriorityList = ['A festive hat','A crumbly egg','Heavenly chip secret','Heavenly cookie stand','Heavenly bakery','Heavenly confectionery','Heavenly key'];
  175. for (var tt in topPriorityList) {
  176. var tp = Game.Upgrades[topPriorityList[tt]];
  177. if (tp.bought === 0 && tp.unlocked == 1) {
  178. tp.buy();
  179. break;
  180. }
  181. }
  182.  
  183. for (var g in Game.UpgradesById) {
  184. if (Game.UpgradesById[g].bought === 0 && Game.UpgradesById[g].unlocked == 1) {
  185. var isMultiplier = Game.UpgradesById[g].desc.indexOf('production multiplier') >= 0;
  186. var isDouble = Game.UpgradesById[g].desc.indexOf('<b>twice</b>') >= 0;
  187. var isDoubleGrandma = Game.UpgradesById[g].desc.indexOf('Grandmas are <b>twice</b>') >= 0;
  188. var isKitten = Game.UpgradesById[g].name.indexOf('Kitten ') >= 0;
  189. var isDoubleCursor = Game.UpgradesById[g].desc.indexOf('The mouse and cursors are <b>twice</b>') >= 0;
  190. var isClickIncrease = Game.UpgradesById[g].desc.indexOf('Clicking gains <b>+1%') >= 0;
  191. var isSpecialTech = Game.UpgradesById[g].pool == 'tech' && typeof Game.UpgradesById[g].clickFunction !== 'undefined';
  192. if (isSpecialTech && Game.UpgradesById[g].clickFunction !== 'undefined' && options.buyInfernalUpgrades) {
  193. delete(Game.UpgradesById[g].clickFunction);
  194. }
  195. var increasedMoney = 0;
  196. if (isClickIncrease) {
  197. increasedMoney = Game.cookiesPs * 0.01;
  198. } else if (isDoubleCursor) {
  199. increasedMoney = Game.Objects['Cursor'].storedTotalCps * Game.globalCpsMult / buffMult;
  200. if (isClickingNow) increasedMoney += Game.computedMouseCps * 1000 / tAutoClickInterval;
  201. } else if (isKitten) {
  202. var kittenPercent = _getKittenPercentByUpgradeName(Game.UpgradesById[g].name);
  203. increasedMoney = _getNormalCookiesPs() * kittenPercent;
  204. } else if (isDoubleGrandma) {
  205. increasedMoney = Game.Objects['Grandma'].storedTotalCps * Game.globalCpsMult / buffMult;
  206. } else if (isMultiplier) {
  207. increasedMoney = _getNormalCookiesPs() * Game.UpgradesById[g].power / 100;
  208. } else if (isDouble) {
  209. increasedMoney = Game.UpgradesById[g].buildingTie.storedTotalCps * Game.globalCpsMult / buffMult;
  210. }
  211. var interest = increasedMoney > 0 ? Game.UpgradesById[g].getPrice() / increasedMoney : '-';
  212. if (interest != '-') {
  213. if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
  214. var pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
  215. if (pp > 50) interest /= pp * 50;
  216. priorityListObj[Math.floor(interest)] = {
  217. name: Game.UpgradesById[g].name,
  218. title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].getPrice()),
  219. price: Game.UpgradesById[g].getPrice(),
  220. cps: 1,
  221. type: 'upgrade',
  222. id: g,
  223. income: increasedMoney
  224. };
  225. }
  226. } else if (Game.UpgradesById[g].type == 'upgrade' &&
  227. Game.UpgradesById[g].getPrice() < moneyCanSpend &&
  228. Game.UpgradesById[g].pool != 'toggle' && (!isSpecialTech || options.buyInfernalUpgrades))
  229. {
  230. interest = Game.UpgradesById[g].getPrice() / moneyCanSpend * 1000;
  231. if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
  232. pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
  233. if (pp > 50) interest /= pp * 50;
  234. priorityListObj[Math.floor(interest)] = {
  235. name: Game.UpgradesById[g].name,
  236. title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].getPrice()),
  237. price: Game.UpgradesById[g].getPrice(),
  238. cps: 1,
  239. type: 'upgrade',
  240. id: g,
  241. income: 0
  242. };
  243. }
  244. }
  245. }
  246. }
  247. for (var i in Game.ObjectsById) {
  248. if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) {
  249. if (Game.ObjectsById[i].locked === 0) {
  250. var cps = (Game.ObjectsById[i].storedTotalCps / Game.ObjectsById[i].amount) * Game.globalCpsMult / buffMult;
  251. interest = Game.ObjectsById[i].price / cps;
  252. var pp = moneyCanSpend / Game.ObjectsById[i].price; // percent of cheapness
  253. if (pp > 50) interest /= pp * 50;
  254. if (isNaN(Math.floor(interest)) && Game.ObjectsById[i].price < moneyCanSpend) interest = 0;
  255. priorityListObj[Math.floor(interest)] = {
  256. name: Game.ObjectsById[i].name,
  257. title: Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price),
  258. price: Game.ObjectsById[i].price,
  259. cps: cps,
  260. type: 'buy',
  261. id: i,
  262. income: cps
  263. };
  264. //priorityList.push(Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price) + ' (INTEREST: ' + Beautify(interest) + ')');
  265. }
  266. }
  267. }
  268. for (i in priorityListObj) {
  269. var prefix = priorityListObj[i].price < moneyCanSpend ? '!!! ' : (priorityListObj[i].price < money ? '! ' : '');
  270. var pp = Math.floor(moneyCanSpend / priorityListObj[i].price * 100);
  271. priorityList.push(prefix + priorityListObj[i].title + ' : ' + i + ' (' + pp + '%)');
  272. }
  273. };
  274.  
  275. var _caption = function(txt) {
  276. var $v = jQuery('#versionNumber');
  277. if ($v.text() != txt) $v.text(txt);
  278. };
  279.  
  280. var _title = function(txt) {
  281. var newTitle = (newLogs > 0 ? '(' + newLogs + ') ' : '') + txt;
  282. if (document.title != newTitle) {
  283. oldTitle = txt;
  284. document.title = newTitle;
  285. }
  286. };
  287.  
  288. var _titlePercent = function(have, need, txt) {
  289. var percent = Math.ceil(have / (need !== 0 ? need : 1) * 100);
  290. _title(String(percent) + "% - " + txt);
  291. };
  292.  
  293. var _logSectionTitle = function (text) {
  294. return '<div class="title">' + text + '</div>';
  295. };
  296.  
  297. var _logSection = function (title, items) {
  298. return '<div class="subsection">' + _logSectionTitle(title) +
  299. '<div class="listing">' + items.join('</div><div class="listing">') + '</div>' +
  300. '</div>';
  301. };
  302.  
  303. var clearLogButton = '<button data-id="clearLog" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Clear Log</button>';
  304. var killWrinklersButton = '<button data-id="killWrinklers" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Kill wrinklers</button>';
  305. var buyEverything = '<button data-id="buyEverything" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Buy everything</button>';
  306.  
  307. var _logPriorityTable = function() {
  308. var moneyCanSpend = _getMoneyCanSpend();
  309. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  310. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Type</th><th>Name</th><th>Price</th><th>Interest</th><th>Income</th><th>% bank</th></tr>';
  311. for (var i in priorityListObj) {
  312. var o = priorityListObj[i];
  313. var pp = Math.floor(moneyCanSpend / o.price * 100);
  314. t += '<tr><td>' + o.type + '</td><td>' + o.name + '</td><td>' + Beautify(o.price) + '</td><td>' + i + '</td><td>' + Beautify(o.income) + '</td><td>' + pp + '</td></tr>';
  315. }
  316. t += '</table>';
  317. return styles + '<div class="subsection">' + _logSectionTitle('Priority ' + clearLogButton + ' ' + killWrinklersButton + ' ' + buyEverything) + '<div class="listing">' + t + '</div></div>';
  318. }
  319.  
  320. var _logNeedBuyTable = function() {
  321. var objList = _getUpgradeListToUnlock();
  322. if (objList && objList.length > 0) {
  323. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  324. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Name</th><th>Price</th><th>Prerequisite</th><th>Season</th></tr>';
  325. for (var i in objList) {
  326. var o = objList[i];
  327. t += '<tr><td>' + o.name + '</td><td>' + Beautify(o.cookies) + '</td><td>' + (typeof o.require !== 'undefined' ? o.require : '') + '</td><td>' + (typeof o.season !== 'undefined' ? o.season : '') + '</td></tr>';
  328. }
  329. t += '</table>';
  330. return styles + '<div class="subsection">' + _logSectionTitle('Need to unlock') + '<div class="listing">' + t + '</div></div>';
  331. } else {
  332. return '';
  333. }
  334. }
  335.  
  336. var _logNeedAchieveTable = function() {
  337. var ach = [];
  338. for (var i in Game.Achievements) {
  339. if(Game.Achievements[i].won === 0 && Game.Achievements[i].pool != 'dungeon') {
  340. ach.push(Game.Achievements[i]);
  341. }
  342. }
  343. if (ach.length > 0) {
  344. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  345. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Name</th><th>Description</th></tr>';
  346. for (i in ach) {
  347. var o = ach[i];
  348. t += '<tr><td>' + o.name + '</td><td>' + o.desc + '</td></tr>';
  349. }
  350. t += '</table>';
  351. return styles + '<div class="subsection">' + _logSectionTitle('Achievements to unlock') + '<div class="listing">' + t + '</div></div>';
  352. } else {
  353. return '';
  354. }
  355. }
  356.  
  357. var _optionsSection = function() {
  358. var content = [];
  359. content.push('<label for="bankStoragePercent" id="bankStoragePercentLabel">Storage (' + Beautify(_getMinimalMoney()) + ') percent: ' + options.bankStoragePercent + '%</label> <input name="bankStoragePercent" id="bankStoragePercent" type="range" min="0" max="100" value="' + options.bankStoragePercent + '" onchange="document.getElementById(\'logButton\').onsliderchange(this)" />');
  360. content.push('<button data-id="bankStorageAuto" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Automatic set of bank storage percent: ' + (options.bankStorageAuto ? 'TRUE' : 'FALSE') + '</button>');
  361. content.push('<button data-id="buyInfernalUpgrades" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Automatic buy infernal upgrades (makes granny evil): ' + (options.buyInfernalUpgrades ? 'TRUE' : 'FALSE') + '</button>');
  362. content.push('<button data-id="noClicking" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Restrict auto clicking: ' + (options.noClicking ? 'TRUE' : 'FALSE') + '</button>');
  363. content.push('<button data-id="autoSeason" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Auto season swithcer: ' + (options.autoSeason ? 'TRUE' : 'FALSE') + '</button>');
  364. content.push(clearLogButton);
  365. return content;
  366. };
  367.  
  368. var _infoSection = function() {
  369. var content = [];
  370.  
  371. var wrinklersTotal = 0;
  372. for (var i in Game.wrinklers) {
  373. wrinklersTotal += Game.wrinklers[i].sucked;
  374. }
  375.  
  376. var chipsOwned = Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
  377. var ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
  378. var ascendWillGet = ascendNowToOwn - chipsOwned;
  379. var cookiesToDoubleInitial = Game.HowManyCookiesReset(chipsOwned * 2) - (Game.cookiesEarned + Game.cookiesReset);
  380. var timeToReachDouble = Math.floor(cookiesToDoubleInitial / _getNormalCookiesPs());
  381.  
  382. content.push('Now clicking: ' + (isClickingNow ? "YES" : "NO"));
  383. content.push('Cookies to double prestige: ' + Beautify(cookiesToDoubleInitial));
  384. content.push('Time to double prestige: ' + Game.sayTime(timeToReachDouble * Game.fps, 2));
  385. content.push('Heavenly chips in storage: ' + Game.heavenlyChips);
  386. content.push('You will get prestige by ascending: ' + ascendWillGet);
  387. content.push('Heavenly chips after ascend: ' + (Game.heavenlyChips + ascendWillGet));
  388. content.push('Buff mult: ' + _getBuffMult());
  389. content.push('Normal CpS: ' + Beautify(_getNormalCookiesPs()));
  390. content.push('Money bank: ' + Beautify(_getMinimalMoney()));
  391. content.push('Money can spend: ' + Beautify(_getMoneyCanSpend()));
  392. content.push('Wrinklers: ' + _getWrinklerCount());
  393. content.push('Wrinklers sucked: ' + Beautify(wrinklersTotal));
  394. return content;
  395. }
  396.  
  397. var _updateLog = function () {
  398. Game.updateLog = logTitle +
  399. _logPriorityTable() +
  400. _logSection('Info', _infoSection()) +
  401. _logSection('Log', log) +
  402. _logSection('Options', _optionsSection()) +
  403. _logNeedBuyTable() +
  404. _logNeedAchieveTable() +
  405. _logSection('History', _history());
  406. var newButtonText = newLogs > 0 ? 'Log (' + newLogs + ')' : 'Log';
  407. if (jQuery('#logButton').text() != newButtonText) jQuery('#logButton').text(newButtonText);
  408. _title(oldTitle);
  409. };
  410.  
  411. var _setBankStogarePercent = function(val, needUpdate) {
  412. if (options.bankStoragePercent != val) {
  413. if (needUpdate === true) jQuery('#bankStoragePercent').val(val);
  414. if (console) console.log('bankStoragePercent =', val);
  415. _store('bankStoragePercent', val);
  416. options.bankStoragePercent = val;
  417. jQuery('#bankStoragePercentLabel').text('Storage (' + Beautify(_getMinimalMoney()) + ') percent: ' + val + '%');
  418. _updateLog();
  419. }
  420. }
  421.  
  422. document.getElementById('logButton').onsliderchange = function(el) {
  423. var val = $(el).val();
  424. _setBankStogarePercent(val);
  425. };
  426.  
  427. var _bankAutoFunction = function() {
  428. if (options.bankStorageAuto && priorityList.length > 0 && Game.OnAscend === 0) {
  429. for (var idx in priorityListObj) {
  430. var bankStorageNew = Math.floor(idx / 50000);
  431. if (bankStorageNew > 100) bankStorageNew = 100;
  432. if (!isNaN(bankStorageNew)) _setBankStogarePercent(bankStorageNew, true);
  433. else if (console) console.log('bankStorageNew error:', idx);
  434. break;
  435. }
  436. }
  437. };
  438.  
  439. var _addLog = function(text, notCritical) {
  440. var t = new Date();
  441. log.push(t.toUTCString() + ': ' + text);
  442. if (notCritical !== true) newLogs++;
  443. _updateLog();
  444. };
  445.  
  446. jQuery('#logButton').text('Log').on("click", function() {
  447. newLogs = 0;
  448. jQuery('#logButton').text('Log');
  449. });
  450.  
  451. var _killAllWrinklers = function (immediately) {
  452. if (typeof immediately === 'undefined') immediately = false;
  453. var wrinklersCount = _getWrinklerCount();
  454. if (wrinklersCount >= 10 || immediately === true) {
  455. var wrinklesIncome = 0;
  456. for (var i in Game.wrinklers) {
  457. wrinklesIncome += Game.wrinklers[i].sucked;
  458. Game.wrinklers[i].hp = 0; // kill ALL
  459. }
  460. if (wrinklesIncome > 0) {
  461. _addLog('Killed all Wrinkles for ' + Beautify(wrinklesIncome) + ' of count ' + wrinklersCount +'.', true);
  462. }
  463. }
  464. };
  465.  
  466. document.getElementById('logButton').onbuttonclick = function(el,e) {
  467. e.preventDefault();
  468. var id = jQuery(el).attr('data-id');
  469. if (id == 'bankStorageAuto') {
  470. options.bankStorageAuto = !options.bankStorageAuto;
  471. _store('bankStorageAuto', options.bankStorageAuto);
  472. if (console) console.log('bankStorageAuto =', options.bankStorageAuto ? 'TRUE' : 'FALSE');
  473. _bankAutoFunction();
  474. } else if (id == 'killWrinklers') {
  475. _killAllWrinklers(true);
  476. } else if (id == 'buyEverything') {
  477. _buyEverything();
  478. } else if (id == 'buyInfernalUpgrades') {
  479. options.buyInfernalUpgrades = !options.buyInfernalUpgrades;
  480. _store('buyInfernalUpgrades', options.buyInfernalUpgrades);
  481. if (console) console.log('buyInfernalUpgrades =', options.buyInfernalUpgrades ? 'TRUE' : 'FALSE');
  482. } else if (id == 'noClicking') {
  483. options.noClicking = !options.noClicking;
  484. _store('noClicking', options.noClicking);
  485. if (console) console.log('noClicking =', options.noClicking ? 'TRUE' : 'FALSE');
  486. } else if (id == 'autoSeason') {
  487. options.autoSeason = !options.autoSeason;
  488. _store('autoSeason', options.autoSeason);
  489. if (console) console.log('autoSeason =', options.autoSeason ? 'TRUE' : 'FALSE');
  490. } else if (id == 'clearLog') {
  491. log = [];
  492. newLogs = 0;
  493. }
  494. jQuery(el).attr('disabled', 'disabled');
  495. _updateLog();
  496. }
  497.  
  498. var _buyEverything = function() {
  499. if (console) console.log('_buyEverything');
  500. for (var x in Game.UpgradesById) {
  501. if (Game.UpgradesById.hasOwnProperty(x)) {
  502. if (Game.UpgradesById[x].unlocked == 1 && Game.UpgradesById[x].bought === 0 && Game.UpgradesById[x].canBuy()) {
  503. var pool = Game.UpgradesById[x].pool;
  504. if (pool != "prestige" &&
  505. pool != 'debug' &&
  506. pool != 'toggle' &&
  507. pool != 'tech' &&
  508. pool != 'shadow' &&
  509. pool != 'unused' &&
  510. pool != 'dungeon')
  511. {
  512. Game.UpgradesById[x].buy();
  513. _addLog('Buy upgrade ' + Game.UpgradesById[x].name + ' for ' + Beautify(Game.UpgradesById[x].getPrice()));
  514. }
  515. }
  516. }
  517. }
  518. for (x in Game.ObjectsById) {
  519. if (Game.ObjectsById.hasOwnProperty(x)) {
  520. var cnt = 0, sum = 0;
  521. while (Game.cookies >= Game.ObjectsById[x].getPrice()) {
  522. sum += Game.ObjectsById[x].getPrice();
  523. Game.ObjectsById[x].buy(1);
  524. cnt++;
  525. }
  526. if (cnt > 0) _addLog('Buy ' + cnt + ' object ' + Game.ObjectsById[x].name + ' for ' + Beautify(sum));
  527. }
  528. }
  529. }
  530.  
  531. var _makeABuy = function() {
  532.  
  533. _killAllWrinklers();
  534.  
  535. var moneyCanSpend = _getMoneyCanSpend();
  536.  
  537. if (moneyCanSpend < 0) {
  538. var minimalMoney = _getMinimalMoney();
  539. _caption('Collecting minimum ' + Beautify(minimalMoney));
  540. _titlePercent(Game.cookies, minimalMoney, 'minimum');
  541. return;
  542. }
  543.  
  544. var needToBuy = undefined, needToBuyInterest = undefined;
  545. if (priorityList.length > 0) {
  546. for (var idx in priorityListObj) {
  547. needToBuy = priorityListObj[idx];
  548. needToBuyInterest = idx;
  549. if (needToBuy.type == 'upgrade') {
  550. _caption('Upgrading ' + needToBuy.name + ' for ' + Beautify(needToBuy.price));
  551. if (needToBuy.price < moneyCanSpend) {
  552. if (Game.UpgradesById[needToBuy.id].canBuy()) {
  553. Game.UpgradesById[needToBuy.id].buy();
  554. _addLog('Buy upgrade ' + Game.UpgradesById[needToBuy.id].name + ' for ' + Beautify(needToBuy.price));
  555. _createPriorityList();
  556. }
  557. } else {
  558. _titlePercent(moneyCanSpend, needToBuy.price, Game.UpgradesById[needToBuy.id].name);
  559. }
  560. } else {
  561. _caption('Collecting ' + Beautify(needToBuy.price) + ' for ' + needToBuy.name);
  562. if (Game.ObjectsById[needToBuy.id].price < moneyCanSpend) {
  563. var amount = 1;
  564. if (Game.ObjectsById[needToBuy.id].getSumPrice(100) < moneyCanSpend) {
  565. Game.ObjectsById[needToBuy.id].buy(100);
  566. amount = 100;
  567. } else if (Game.ObjectsById[needToBuy.id].getSumPrice(10) < moneyCanSpend) {
  568. Game.ObjectsById[needToBuy.id].buy(10);
  569. amount = 10;
  570. } else {
  571. Game.ObjectsById[needToBuy.id].buy(1);
  572. }
  573. _addLog('Buy ' + amount + ' object ' + Game.ObjectsById[needToBuy.id].name + ' for ' + Beautify(Game.ObjectsById[needToBuy.id].price));
  574. _createPriorityList();
  575. } else {
  576. _titlePercent(moneyCanSpend, needToBuy.price, Game.ObjectsById[needToBuy.id].name);
  577. }
  578. }
  579. break;
  580. }
  581. }
  582. };
  583.  
  584. var startT = function() {
  585. t2 = setInterval(_makeABuy, 500);
  586.  
  587. started = true;
  588. _caption('Started');
  589. _addLog('Autobuy start!', true);
  590. };
  591.  
  592. var stopT = function() {
  593. clearInterval(t2);
  594. started = false;
  595. _caption('Collecting gold...');
  596. _addLog('Autobuy stop.', true);
  597. };
  598.  
  599. jQuery('#versionNumber').on("click", function() {
  600. if (!started)
  601. startT();
  602. else
  603. stopT();
  604. });
  605.  
  606. var _restoreAll = function() {
  607. options.bankStoragePercent = parseInt(_restore('bankStoragePercent'));
  608. if (typeof options.bankStoragePercent === 'undefined' || options.bankStoragePercent === null) {
  609. options.bankStoragePercent = 100;
  610. }
  611. options.bankStorageAuto = _restore('bankStorageAuto', true);
  612. if (typeof options.bankStorageAuto === 'undefined' || options.bankStorageAuto === null) {
  613. options.bankStorageAuto = false;
  614. }
  615. options.buyInfernalUpgrades = _restore('buyInfernalUpgrades', true);
  616. if (typeof options.buyInfernalUpgrades === 'undefined' || options.buyInfernalUpgrades === null) {
  617. options.buyInfernalUpgrades = false;
  618. }
  619. options.noClicking = _restore('noClicking', true);
  620. if (typeof options.noClicking === 'undefined' || options.noClicking === null) {
  621. options.noClicking = false;
  622. }
  623. options.autoSeason = _restore('autoSeason', true);
  624. if (typeof options.autoSeason === 'undefined' || options.autoSeason === null) {
  625. options.autoSeason = false;
  626. }
  627. }
  628.  
  629. var _seasonSwitcher = function() {
  630. if (!options.autoSeason) return;
  631. if (_getWrinklerCount() >= 8) {
  632. var halloweenSeason = ['Skull cookies','Ghost cookies','Bat cookies','Slime cookies','Pumpkin cookies','Eyeball cookies','Spider cookies'];
  633. for (var x in halloweenSeason) {
  634. if (halloweenSeason.hasOwnProperty(x) && Game.Upgrades[halloweenSeason[x]].bought === 0) {
  635. if (Game.season != 'halloween') {
  636. Game.Upgrades['Ghostly biscuit'].buy();
  637. _killAllWrinklers(true);
  638. return;
  639. }
  640. }
  641. }
  642. }
  643. if (Game.Has('A crumbly egg') && Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost()) {
  644. Game.UpgradeDragon();
  645. Game.specialTab = 'Hello';
  646. Game.ToggleSpecialMenu(0);
  647. }
  648.  
  649. if (!Game.Has('Santa\'s dominion')) {
  650. if (Game.season != 'christmas') {
  651. Game.Upgrades['Festive biscuit'].buy();
  652. } else {
  653. if (Game.Has('A festive hat')) {
  654. for (var i = 0; i < (14 - Game.santaLevel); i++) Game.UpgradeSanta();
  655. Game.specialTab = 'Hello';
  656. Game.ToggleSpecialMenu(0);
  657. }
  658. }
  659. return;
  660. }
  661. var valentines = ['Pure heart biscuits','Ardent heart biscuits','Sour heart biscuits','Weeping heart biscuits','Golden heart biscuits','Eternal heart biscuits'];
  662. for (x in valentines) {
  663. if (valentines.hasOwnProperty(x) && Game.Upgrades[valentines[x]].bought === 0) {
  664. if (Game.season != 'valentines') {
  665. Game.Upgrades['Lovesick biscuit'].buy();
  666. }
  667. return;
  668. }
  669. }
  670.  
  671. for (x in Game.easterEggs) {
  672. if (Game.easterEggs.hasOwnProperty(x) && Game.Upgrades[Game.easterEggs[x]].bought === 0) {
  673. if (Game.season != 'easter') {
  674. Game.Upgrades['Bunny biscuit'].buy();
  675. }
  676. return;
  677. }
  678. }
  679.  
  680. if (Game.season != 'christmas') {
  681. Game.Upgrades['Festive biscuit'].buy();
  682. }
  683. }
  684.  
  685. _restoreAll();
  686.  
  687. setTimeout(function() {
  688. jQuery('#donateBox').hide();
  689.  
  690. tSeasonSwitcher = setInterval(_seasonSwitcher, 3000);
  691.  
  692. tPriority = setInterval(function () {
  693. _createPriorityList();
  694. _updateLog();
  695. }, 1000);
  696.  
  697. tLog = setInterval(function () {
  698. _updateLog();
  699. }, 600);
  700.  
  701. tReloadPageOnWrongBuff = setInterval(function() {
  702. if (_getBuffMult() < 1) {
  703. var hasBuffsToKill = false;
  704. for (var buff in Game.buffs) {
  705. if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') {
  706. Game.buffs[buff].time = 0; // remove all buffs, not only negative (not cheating)
  707. hasBuffsToKill = true;
  708. }
  709. }
  710. if (hasBuffsToKill) _addLog('Remove all buffs because of negative multiplier', true);
  711. }
  712. }, 1000);
  713.  
  714. tAscendDetector = setInterval(function() {
  715. if (Game.OnAscend == 1) {
  716. _setBankStogarePercent(0, true);
  717. }
  718. }, 1000);
  719.  
  720. t3 = setInterval(function() {
  721. var golden = Game.shimmers;
  722. if (golden.length > 0) {
  723. for (var i in golden) {
  724. golden[i].pop();
  725. }
  726. }
  727. }, 500);
  728.  
  729. tBankAuto = setInterval(_bankAutoFunction, 600001); // 10 minutes
  730.  
  731. tClickFrenzy = setInterval(function() {
  732. if (options.noClicking) return;
  733. var date=new Date();
  734. date.setTime(Date.now()-Game.startDate);
  735. var seconds = date.getTime() / 1000;
  736. var buffMult = _getBuffMult();
  737. if (buffMult >= 15 ||
  738. Game.hasBuff('Click frenzy') ||
  739. Game.hasBuff('Cursed finger') ||
  740. Game.hasBuff('Elder frenzy') ||
  741. Game.hasBuff('Dragon Harvest') ||
  742. Game.hasBuff('Dragonflight') ||
  743. Game.cookiesPs < 1000000 ||
  744. seconds < 1000)
  745. {
  746. Game.mouseX = jQuery('#bigCookie').width() / 2 + jQuery('#bigCookie').offset().left;
  747. Game.mouseY = jQuery('#bigCookie').height() / 2 + jQuery('#bigCookie').offset().top;
  748. Game.ClickCookie();
  749. isClickingNow = true;
  750. } else {
  751. isClickingNow = false;
  752. }
  753. }, tAutoClickInterval);
  754.  
  755. _caption('Collecting gold...');
  756. _createPriorityList();
  757. _updateLog();
  758.  
  759. _bankAutoFunction();
  760. }, 5000);
  761. })();