Cookie clicker tools

Cookie clicker tools (visual)

目前为 2017-03-15 提交的版本。查看 最新版本

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