Cookie clicker tools

Cookie clicker tools (visual)

目前为 2017-03-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Cookie clicker tools
  3. // @namespace orteil.dashnet.org
  4. // @version 2.133
  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.133 is here!</div>', newLogs = 0;
  14.  
  15. var started = false, t2, t3, tClickFrenzy, oldTitle = '', tLog,
  16. tPriority, tBankAuto, tAscendDetector, isClickingNow = false,
  17. tSeasonSwitcher, tReloadPageOnWrongBuff, tAutoClickInterval = 75;
  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. if (isClickingNow) increasedMoney += Game.computedMouseCps * 1000 / tAutoClickInterval;
  195. } else if (isKitten) {
  196. var kittenPercent = _getKittenPercentByUpgradeName(Game.UpgradesById[g].name);
  197. increasedMoney = _getNormalCookiesPs() * kittenPercent;
  198. } else if (isDoubleGrandma) {
  199. increasedMoney = Game.Objects['Grandma'].storedTotalCps * Game.globalCpsMult / buffMult;
  200. } else if (isMultiplier) {
  201. increasedMoney = _getNormalCookiesPs() * Game.UpgradesById[g].power / 100;
  202. } else if (isDouble) {
  203. increasedMoney = Game.UpgradesById[g].buildingTie.storedTotalCps * Game.globalCpsMult / buffMult;
  204. }
  205. var interest = increasedMoney > 0 ? Game.UpgradesById[g].getPrice() / increasedMoney : '-';
  206. if (interest != '-') {
  207. if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
  208. var pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
  209. if (pp > 50) interest /= pp * 50;
  210. priorityListObj[Math.floor(interest)] = {
  211. name: Game.UpgradesById[g].name,
  212. title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].getPrice()),
  213. price: Game.UpgradesById[g].getPrice(),
  214. cps: 1,
  215. type: 'upgrade',
  216. id: g,
  217. income: increasedMoney
  218. };
  219. }
  220. } else if (Game.UpgradesById[g].type == 'upgrade' &&
  221. Game.UpgradesById[g].getPrice() < moneyCanSpend &&
  222. Game.UpgradesById[g].pool != 'toggle' && (!isSpecialTech || options.buyInfernalUpgrades))
  223. {
  224. interest = Game.UpgradesById[g].getPrice() / moneyCanSpend * 1000;
  225. if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
  226. pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
  227. if (pp > 50) interest /= pp * 50;
  228. priorityListObj[Math.floor(interest)] = {
  229. name: Game.UpgradesById[g].name,
  230. title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].getPrice()),
  231. price: Game.UpgradesById[g].getPrice(),
  232. cps: 1,
  233. type: 'upgrade',
  234. id: g,
  235. income: 0
  236. };
  237. }
  238. }
  239. }
  240. }
  241. for (var i in Game.ObjectsById) {
  242. if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) {
  243. if (Game.ObjectsById[i].locked === 0) {
  244. var cps = (Game.ObjectsById[i].storedTotalCps / Game.ObjectsById[i].amount) * Game.globalCpsMult / buffMult;
  245. interest = Game.ObjectsById[i].price / cps;
  246. var pp = moneyCanSpend / Game.ObjectsById[i].price; // percent of cheapness
  247. if (pp > 50) interest /= pp * 50;
  248. if (isNaN(Math.floor(interest)) && Game.ObjectsById[i].price < moneyCanSpend) interest = 0;
  249. priorityListObj[Math.floor(interest)] = {
  250. name: Game.ObjectsById[i].name,
  251. title: Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price),
  252. price: Game.ObjectsById[i].price,
  253. cps: cps,
  254. type: 'buy',
  255. id: i,
  256. income: cps
  257. };
  258. //priorityList.push(Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price) + ' (INTEREST: ' + Beautify(interest) + ')');
  259. }
  260. }
  261. }
  262. for (i in priorityListObj) {
  263. var prefix = priorityListObj[i].price < moneyCanSpend ? '!!! ' : (priorityListObj[i].price < money ? '! ' : '');
  264. var pp = Math.floor(moneyCanSpend / priorityListObj[i].price * 100);
  265. priorityList.push(prefix + priorityListObj[i].title + ' : ' + i + ' (' + pp + '%)');
  266. }
  267. };
  268.  
  269. var _caption = function(txt) {
  270. var $v = jQuery('#versionNumber');
  271. if ($v.text() != txt) $v.text(txt);
  272. };
  273.  
  274. var _title = function(txt) {
  275. var newTitle = (newLogs > 0 ? '(' + newLogs + ') ' : '') + txt;
  276. if (document.title != newTitle) {
  277. oldTitle = txt;
  278. document.title = newTitle;
  279. }
  280. };
  281.  
  282. var _titlePercent = function(have, need, txt) {
  283. var percent = Math.ceil(have / (need !== 0 ? need : 1) * 100);
  284. _title(String(percent) + "% - " + txt);
  285. };
  286.  
  287. var _logSectionTitle = function (text) {
  288. return '<div class="title">' + text + '</div>';
  289. };
  290.  
  291. var _logSection = function (title, items) {
  292. return '<div class="subsection">' + _logSectionTitle(title) +
  293. '<div class="listing">' + items.join('</div><div class="listing">') + '</div>' +
  294. '</div>';
  295. };
  296.  
  297. var clearLogButton = '<button data-id="clearLog" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Clear Log</button>';
  298. var killWrinklersButton = '<button data-id="killWrinklers" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Kill wrinklers</button>';
  299.  
  300. var _logPriorityTable = function() {
  301. var moneyCanSpend = _getMoneyCanSpend();
  302. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  303. 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>';
  304. for (var i in priorityListObj) {
  305. var o = priorityListObj[i];
  306. var pp = Math.floor(moneyCanSpend / o.price * 100);
  307. 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>';
  308. }
  309. t += '</table>';
  310. return styles + '<div class="subsection">' + _logSectionTitle('Priority ' + clearLogButton + ' ' + killWrinklersButton) + '<div class="listing">' + t + '</div></div>';
  311. }
  312.  
  313. var _logNeedBuyTable = function() {
  314. var objList = _getUpgradeListToUnlock();
  315. if (objList && objList.length > 0) {
  316. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  317. 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>';
  318. for (var i in objList) {
  319. var o = objList[i];
  320. 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>';
  321. }
  322. t += '</table>';
  323. return styles + '<div class="subsection">' + _logSectionTitle('Need to unlock') + '<div class="listing">' + t + '</div></div>';
  324. } else {
  325. return '';
  326. }
  327. }
  328.  
  329. var _logNeedAchieveTable = function() {
  330. var ach = [];
  331. for (var i in Game.Achievements) {
  332. if(Game.Achievements[i].won === 0 && Game.Achievements[i].pool != 'dungeon') {
  333. ach.push(Game.Achievements[i]);
  334. }
  335. }
  336. if (ach.length > 0) {
  337. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  338. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Name</th><th>Description</th></tr>';
  339. for (i in ach) {
  340. var o = ach[i];
  341. t += '<tr><td>' + o.name + '</td><td>' + o.desc + '</td></tr>';
  342. }
  343. t += '</table>';
  344. return styles + '<div class="subsection">' + _logSectionTitle('Achievements to unlock') + '<div class="listing">' + t + '</div></div>';
  345. } else {
  346. return '';
  347. }
  348. }
  349.  
  350. var _optionsSection = function() {
  351. var content = [];
  352. 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)" />');
  353. content.push('<button data-id="bankStorageAuto" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Automatic set of bank storage percent: ' + (options.bankStorageAuto ? 'TRUE' : 'FALSE') + '</button>');
  354. 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>');
  355. content.push('<button data-id="noClicking" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Restrict auto clicking: ' + (options.noClicking ? 'TRUE' : 'FALSE') + '</button>');
  356. content.push('<button data-id="autoSeason" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Auto season swithcer: ' + (options.autoSeason ? 'TRUE' : 'FALSE') + '</button>');
  357. content.push(clearLogButton);
  358. return content;
  359. };
  360.  
  361. var _infoSection = function() {
  362. var content = [];
  363.  
  364. var wrinklersTotal = 0;
  365. for (var i in Game.wrinklers) {
  366. wrinklersTotal += Game.wrinklers[i].sucked;
  367. }
  368.  
  369. var chipsOwned = Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
  370. var ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
  371. var ascendWillGet = ascendNowToOwn - chipsOwned;
  372. var cookiesToDoubleInitial = Game.HowManyCookiesReset(chipsOwned * 2) - (Game.cookiesEarned + Game.cookiesReset);
  373. var timeToReachDouble = Math.floor(cookiesToDoubleInitial / _getNormalCookiesPs());
  374.  
  375. content.push('Now clicking: ' + (isClickingNow ? "YES" : "NO"));
  376. content.push('Cookies to double prestige: ' + Beautify(cookiesToDoubleInitial));
  377. content.push('Time to double prestige: ' + Game.sayTime(timeToReachDouble * Game.fps, 2));
  378. content.push('Heavenly chips in storage: ' + Game.heavenlyChips);
  379. content.push('You will get prestige by ascending: ' + ascendWillGet);
  380. content.push('Heavenly chips after ascend: ' + (Game.heavenlyChips + ascendWillGet));
  381. content.push('Buff mult: ' + _getBuffMult());
  382. content.push('Normal CpS: ' + Beautify(_getNormalCookiesPs()));
  383. content.push('Money bank: ' + Beautify(_getMinimalMoney()));
  384. content.push('Money can spend: ' + Beautify(_getMoneyCanSpend()));
  385. content.push('Wrinklers: ' + _getWrinklerCount());
  386. content.push('Wrinklers sucked: ' + Beautify(wrinklersTotal));
  387. return content;
  388. }
  389.  
  390. var _updateLog = function () {
  391. Game.updateLog = logTitle +
  392. _logPriorityTable() +
  393. _logSection('Info', _infoSection()) +
  394. _logSection('Log', log) +
  395. _logSection('Options', _optionsSection()) +
  396. _logNeedBuyTable() +
  397. _logNeedAchieveTable() +
  398. _logSection('History', _history());
  399. var newButtonText = newLogs > 0 ? 'Log (' + newLogs + ')' : 'Log';
  400. if (jQuery('#logButton').text() != newButtonText) jQuery('#logButton').text(newButtonText);
  401. _title(oldTitle);
  402. };
  403.  
  404. var _setBankStogarePercent = function(val, needUpdate) {
  405. if (options.bankStoragePercent != val) {
  406. if (needUpdate === true) jQuery('#bankStoragePercent').val(val);
  407. if (console) console.log('bankStoragePercent =', val);
  408. _store('bankStoragePercent', val);
  409. options.bankStoragePercent = val;
  410. jQuery('#bankStoragePercentLabel').text('Storage (' + Beautify(_getMinimalMoney()) + ') percent: ' + val + '%');
  411. _updateLog();
  412. }
  413. }
  414.  
  415. document.getElementById('logButton').onsliderchange = function(el) {
  416. var val = $(el).val();
  417. _setBankStogarePercent(val);
  418. };
  419.  
  420. var _bankAutoFunction = function() {
  421. if (options.bankStorageAuto && priorityList.length > 0 && Game.OnAscend === 0) {
  422. for (var idx in priorityListObj) {
  423. var bankStorageNew = Math.floor(idx / 50000);
  424. if (bankStorageNew > 100) bankStorageNew = 100;
  425. if (!isNaN(bankStorageNew)) _setBankStogarePercent(bankStorageNew, true);
  426. else if (console) console.log('bankStorageNew error:', idx);
  427. break;
  428. }
  429. }
  430. };
  431.  
  432. var _addLog = function(text, notCritical) {
  433. var t = new Date();
  434. log.push(t.toUTCString() + ': ' + text);
  435. if (notCritical !== true) newLogs++;
  436. _updateLog();
  437. };
  438.  
  439. jQuery('#logButton').text('Log').on("click", function() {
  440. newLogs = 0;
  441. jQuery('#logButton').text('Log');
  442. });
  443.  
  444. var _killAllWrinklers = function (immediately) {
  445. if (typeof immediately === 'undefined') immediately = false;
  446. var wrinklersCount = _getWrinklerCount();
  447. if (wrinklersCount >= 10 || immediately === true) {
  448. var wrinklesIncome = 0;
  449. for (var i in Game.wrinklers) {
  450. wrinklesIncome += Game.wrinklers[i].sucked;
  451. Game.wrinklers[i].hp = 0; // kill ALL
  452. }
  453. if (wrinklesIncome > 0) {
  454. _addLog('Killed all Wrinkles for ' + Beautify(wrinklesIncome) + ' of count ' + wrinklersCount +'.', true);
  455. }
  456. }
  457. };
  458.  
  459. document.getElementById('logButton').onbuttonclick = function(el,e) {
  460. e.preventDefault();
  461. var id = jQuery(el).attr('data-id');
  462. if (id == 'bankStorageAuto') {
  463. options.bankStorageAuto = !options.bankStorageAuto;
  464. _store('bankStorageAuto', options.bankStorageAuto);
  465. if (console) console.log('bankStorageAuto =', options.bankStorageAuto ? 'TRUE' : 'FALSE');
  466. _bankAutoFunction();
  467. } else if (id == 'killWrinklers') {
  468. _killAllWrinklers(true);
  469. } else if (id == 'buyInfernalUpgrades') {
  470. options.buyInfernalUpgrades = !options.buyInfernalUpgrades;
  471. _store('buyInfernalUpgrades', options.buyInfernalUpgrades);
  472. if (console) console.log('buyInfernalUpgrades =', options.buyInfernalUpgrades ? 'TRUE' : 'FALSE');
  473. } else if (id == 'noClicking') {
  474. options.noClicking = !options.noClicking;
  475. _store('noClicking', options.noClicking);
  476. if (console) console.log('noClicking =', options.noClicking ? 'TRUE' : 'FALSE');
  477. } else if (id == 'autoSeason') {
  478. options.autoSeason = !options.autoSeason;
  479. _store('autoSeason', options.autoSeason);
  480. if (console) console.log('autoSeason =', options.autoSeason ? 'TRUE' : 'FALSE');
  481. } else if (id == 'clearLog') {
  482. log = [];
  483. newLogs = 0;
  484. }
  485. jQuery(el).attr('disabled', 'disabled');
  486. _updateLog();
  487. }
  488.  
  489. var _makeABuy = function() {
  490.  
  491. _killAllWrinklers();
  492.  
  493. var moneyCanSpend = _getMoneyCanSpend();
  494.  
  495. if (moneyCanSpend < 0) {
  496. var minimalMoney = _getMinimalMoney();
  497. _caption('Collecting minimum ' + Beautify(minimalMoney));
  498. _titlePercent(Game.cookies, minimalMoney, 'minimum');
  499. return;
  500. }
  501.  
  502. var needToBuy = undefined, needToBuyInterest = undefined;
  503. if (priorityList.length > 0) {
  504. for (var idx in priorityListObj) {
  505. needToBuy = priorityListObj[idx];
  506. needToBuyInterest = idx;
  507. if (needToBuy.type == 'upgrade') {
  508. _caption('Upgrading ' + needToBuy.name + ' for ' + Beautify(needToBuy.price));
  509. if (needToBuy.price < moneyCanSpend) {
  510. if (Game.UpgradesById[needToBuy.id].canBuy()) {
  511. Game.UpgradesById[needToBuy.id].buy();
  512. _addLog('Buy upgrade ' + Game.UpgradesById[needToBuy.id].name + ' for ' + Beautify(needToBuy.price));
  513. _createPriorityList();
  514. }
  515. } else {
  516. _titlePercent(moneyCanSpend, needToBuy.price, Game.UpgradesById[needToBuy.id].name);
  517. }
  518. } else {
  519. _caption('Collecting ' + Beautify(needToBuy.price) + ' for ' + needToBuy.name);
  520. if (Game.ObjectsById[needToBuy.id].price < moneyCanSpend) {
  521. var amount = 1;
  522. if (Game.ObjectsById[needToBuy.id].getSumPrice(100) < moneyCanSpend) {
  523. Game.ObjectsById[needToBuy.id].buy(100);
  524. amount = 100;
  525. } else if (Game.ObjectsById[needToBuy.id].getSumPrice(10) < moneyCanSpend) {
  526. Game.ObjectsById[needToBuy.id].buy(10);
  527. amount = 10;
  528. } else {
  529. Game.ObjectsById[needToBuy.id].buy(1);
  530. }
  531. _addLog('Buy ' + amount + ' object ' + Game.ObjectsById[needToBuy.id].name + ' for ' + Beautify(Game.ObjectsById[needToBuy.id].price));
  532. _createPriorityList();
  533. } else {
  534. _titlePercent(moneyCanSpend, needToBuy.price, Game.ObjectsById[needToBuy.id].name);
  535. }
  536. }
  537. break;
  538. }
  539. }
  540. };
  541.  
  542. var startT = function() {
  543. t2 = setInterval(_makeABuy, 500);
  544.  
  545. started = true;
  546. _caption('Started');
  547. _addLog('Autobuy start!', true);
  548. };
  549.  
  550. var stopT = function() {
  551. clearInterval(t2);
  552. started = false;
  553. _caption('Collecting gold...');
  554. _addLog('Autobuy stop.', true);
  555. };
  556.  
  557. jQuery('#versionNumber').on("click", function() {
  558. if (!started)
  559. startT();
  560. else
  561. stopT();
  562. });
  563.  
  564. var _restoreAll = function() {
  565. options.bankStoragePercent = parseInt(_restore('bankStoragePercent'));
  566. if (typeof options.bankStoragePercent === 'undefined' || options.bankStoragePercent === null) {
  567. options.bankStoragePercent = 100;
  568. }
  569. options.bankStorageAuto = _restore('bankStorageAuto', true);
  570. if (typeof options.bankStorageAuto === 'undefined' || options.bankStorageAuto === null) {
  571. options.bankStorageAuto = false;
  572. }
  573. options.buyInfernalUpgrades = _restore('buyInfernalUpgrades', true);
  574. if (typeof options.buyInfernalUpgrades === 'undefined' || options.buyInfernalUpgrades === null) {
  575. options.buyInfernalUpgrades = false;
  576. }
  577. options.noClicking = _restore('noClicking', true);
  578. if (typeof options.noClicking === 'undefined' || options.noClicking === null) {
  579. options.noClicking = false;
  580. }
  581. options.autoSeason = _restore('autoSeason', true);
  582. if (typeof options.autoSeason === 'undefined' || options.autoSeason === null) {
  583. options.autoSeason = false;
  584. }
  585. }
  586.  
  587. var _seasonSwitcher = function() {
  588. if (!options.autoSeason) return;
  589. if (_getWrinklerCount() >= 8) {
  590. var halloweenSeason = ['Skull cookies','Ghost cookies','Bat cookies','Slime cookies','Pumpkin cookies','Eyeball cookies','Spider cookies'];
  591. for (var x in halloweenSeason) {
  592. if (halloweenSeason.hasOwnProperty(x) && Game.Upgrades[halloweenSeason[x]].bought === 0) {
  593. if (Game.season != 'halloween') {
  594. Game.Upgrades['Ghostly biscuit'].buy();
  595. _killAllWrinklers(true);
  596. return;
  597. }
  598. }
  599. }
  600. }
  601. if (Game.Has('A crumbly egg') && Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost()) {
  602. Game.UpgradeDragon();
  603. Game.specialTab = 'Hello';
  604. Game.ToggleSpecialMenu(0);
  605. }
  606.  
  607. if (!Game.Has('Santa\'s dominion')) {
  608. if (Game.season != 'christmas') {
  609. Game.Upgrades['Festive biscuit'].buy();
  610. } else {
  611. if (Game.Has('A festive hat')) {
  612. for (var i = 0; i < (14 - Game.santaLevel); i++) Game.UpgradeSanta();
  613. Game.specialTab = 'Hello';
  614. Game.ToggleSpecialMenu(0);
  615. }
  616. }
  617. return;
  618. }
  619. var valentines = ['Pure heart biscuits','Ardent heart biscuits','Sour heart biscuits','Weeping heart biscuits','Golden heart biscuits','Eternal heart biscuits'];
  620. for (x in valentines) {
  621. if (valentines.hasOwnProperty(x) && Game.Upgrades[valentines[x]].bought === 0) {
  622. if (Game.season != 'valentines') {
  623. Game.Upgrades['Lovesick biscuit'].buy();
  624. }
  625. return;
  626. }
  627. }
  628.  
  629. for (x in Game.easterEggs) {
  630. if (Game.easterEggs.hasOwnProperty(x) && Game.Upgrades[Game.easterEggs[x]].bought === 0) {
  631. if (Game.season != 'easter') {
  632. Game.Upgrades['Bunny biscuit'].buy();
  633. }
  634. return;
  635. }
  636. }
  637.  
  638. if (Game.season != 'christmas') {
  639. Game.Upgrades['Festive biscuit'].buy();
  640. }
  641. }
  642.  
  643. _restoreAll();
  644.  
  645. setTimeout(function() {
  646. jQuery('#donateBox').hide();
  647.  
  648. tSeasonSwitcher = setInterval(_seasonSwitcher, 3000);
  649.  
  650. tPriority = setInterval(function () {
  651. _createPriorityList();
  652. _updateLog();
  653. }, 1000);
  654.  
  655. tLog = setInterval(function () {
  656. _updateLog();
  657. }, 600);
  658.  
  659. tReloadPageOnWrongBuff = setInterval(function() {
  660. if (_getBuffMult() < 1) {
  661. var hasBuffsToKill = false;
  662. for (var buff in Game.buffs) {
  663. if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') {
  664. Game.buffs[buff].time = 0; // remove all buffs, not only negative (not cheating)
  665. hasBuffsToKill = true;
  666. }
  667. }
  668. if (hasBuffsToKill) _addLog('Remove all buffs because of negative multiplier', true);
  669. }
  670. }, 1000);
  671.  
  672. tAscendDetector = setInterval(function() {
  673. if (Game.OnAscend == 1) {
  674. _setBankStogarePercent(0, true);
  675. }
  676. }, 1000);
  677.  
  678. t3 = setInterval(function() {
  679. var golden = Game.shimmers;
  680. if (golden.length > 0) {
  681. for (var i in golden) {
  682. golden[i].pop();
  683. }
  684. }
  685. }, 500);
  686.  
  687. tBankAuto = setInterval(_bankAutoFunction, 600001); // 10 minutes
  688.  
  689. tClickFrenzy = setInterval(function() {
  690. if (options.noClicking) return;
  691. var date=new Date();
  692. date.setTime(Date.now()-Game.startDate);
  693. var seconds = date.getTime() / 1000;
  694. var buffMult = _getBuffMult();
  695. if (buffMult >= 15 ||
  696. Game.hasBuff('Click frenzy') ||
  697. Game.hasBuff('Cursed finger') ||
  698. Game.hasBuff('Elder frenzy') ||
  699. Game.hasBuff('Dragon Harvest') ||
  700. Game.hasBuff('Dragonflight') ||
  701. Game.cookiesPs < 1000000 ||
  702. seconds < 1000)
  703. {
  704. Game.mouseX = jQuery('#bigCookie').width() / 2 + jQuery('#bigCookie').offset().left;
  705. Game.mouseY = jQuery('#bigCookie').height() / 2 + jQuery('#bigCookie').offset().top;
  706. Game.ClickCookie();
  707. isClickingNow = true;
  708. } else {
  709. isClickingNow = false;
  710. }
  711. }, tAutoClickInterval);
  712.  
  713. _caption('Collecting gold...');
  714. _createPriorityList();
  715. _updateLog();
  716.  
  717. _bankAutoFunction();
  718. }, 5000);
  719. })();