Cookie clicker tools

Cookie clicker tools (visual)

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

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