Cookie clicker tools

Cookie clicker tools (visual)

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

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