您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Cookie clicker tools (visual)
当前为
// ==UserScript== // @name Cookie clicker tools // @namespace orteil.dashnet.org // @version 2.094 // @description Cookie clicker tools (visual) // @author Anton // @match http://orteil.dashnet.org/cookieclicker/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // ==/UserScript== (function() { 'use strict'; var log = [], logTitle = '<div class="section">Cookie clicker tools 2.094 is here!</div>', newLogs = 0; var started = false, t2, t3, tClick, tClickFrenzy, oldTitle = '', tLog, tPriority; var _history = function() { var hist = []; hist.push('2.094 - objects CpS fix (buffs)'); hist.push('2.093 - objects CpS fix'); hist.push('2.092 - priority table fix'); hist.push('2.091 - priority table refactor'); hist.push('2.090 - buy very cheap items first'); hist.push('2.089 - fix pool toggle buy'); hist.push('2.088 - fix'); hist.push('2.087 - fix buy unknown upgrades'); hist.push('2.086 - clear log button'); hist.push('2.085 - fix'); hist.push('2.084 - buy unknown upgrades if their price is 0.1% of cookie storage'); hist.push('2.083 - mouse upgrades is processed as Upgrades'); hist.push('2.082 - start from scratch'); hist.push('2.081 - fix'); hist.push('2.080 - add history, add option "showTimeCompensate"'); hist.push('2.079 - hide donate box'); hist.push('2.078 - Kittens now is processed as Upgrades'); hist.push(''); hist.push(''); return hist; } var _getKittenPercentByUpgradeName = function(kName) { if (kName == 'Kitten helpers') return Game.milkProgress*0.1; if (kName == 'Kitten workers') return Game.milkProgress*0.125; if (kName == 'Kitten engineers') return Game.milkProgress*0.15; if (kName == 'Kitten overseers') return Game.milkProgress*0.175; if (kName == 'Kitten managers') return Game.milkProgress*0.2; if (kName == 'Kitten accountants') return Game.milkProgress*0.2; if (kName == 'Kitten specialists') return Game.milkProgress*0.2; if (kName == 'Kitten experts') return Game.milkProgress*0.2; if (kName == 'Kitten angels') return Game.milkProgress*0.1; return 0; } var options = { bankStoragePercent: 100, showTimeCompensate: false }; var _store = function(name, value) { if (typeof(Storage) !== "undefined") localStorage.setItem(name, value); }; var _restore = function(name) { if (typeof(Storage) !== "undefined") return localStorage.getItem(name); else return undefined; }; var _getBuffMult = function () { var buffMult = 1; for (var buff in Game.buffs) { if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') { buffMult = buffMult * Game.buffs[buff].multCpS; } } return buffMult === 0 ? 1 : buffMult; }; var _getNormalCookiesPs = function () { return Game.cookiesPs / _getBuffMult(); }; var _getMinimalMoney = function () { return Math.floor(_getNormalCookiesPs() * 42100 * options.bankStoragePercent / 100); }; var _getMoneyCanSpend = function () { var moneyCanSpend = Game.cookies - _getMinimalMoney(); return moneyCanSpend; }; var priorityListObj = {}, priorityList = [], timeCompensateObj = {}, timeCompensateList = []; var _createPriorityList = function() { var moneyCanSpend = _getMoneyCanSpend(); var money = Game.cookies; var buffMult = _getBuffMult(); priorityList = []; priorityListObj = {}; for (var g in Game.UpgradesById) { if (Game.UpgradesById[g].bought === 0 && Game.UpgradesById[g].unlocked == 1) { var isMultiplier = Game.UpgradesById[g].desc.indexOf('production multiplier') >= 0; var isDouble = Game.UpgradesById[g].desc.indexOf('<b>twice</b>') >= 0; var isDoubleGrandma = Game.UpgradesById[g].desc.indexOf('Grandmas are <b>twice</b>') >= 0; var isKitten = Game.UpgradesById[g].name.indexOf('Kitten ') >= 0; var isDoubleCursor = Game.UpgradesById[g].desc.indexOf('The mouse and cursors are <b>twice</b>') >= 0; var increasedMoney = 0; if (isDoubleCursor) { increasedMoney = Game.Objects['Cursor'].storedTotalCps * Game.globalCpsMult / buffMult; } else if (isKitten) { var kittenPercent = _getKittenPercentByUpgradeName(Game.UpgradesById[g].name); increasedMoney = _getNormalCookiesPs() * kittenPercent; } else if (isDoubleGrandma) { increasedMoney = Game.Objects['Grandma'].storedTotalCps * Game.globalCpsMult / buffMult; } else if (isMultiplier) { increasedMoney = _getNormalCookiesPs() * Game.UpgradesById[g].power / 100; } else if (isDouble) { increasedMoney = Game.UpgradesById[g].buildingTie.storedTotalCps * Game.globalCpsMult / buffMult; } var interest = increasedMoney > 0 ? Game.UpgradesById[g].basePrice / increasedMoney : '-'; if (interest != '-') { if (typeof priorityListObj[Math.floor(interest)] === 'undefined') { priorityListObj[Math.floor(interest)] = { name: Game.UpgradesById[g].name, title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].basePrice), price: Game.UpgradesById[g].basePrice, cps: 1, type: 'upgrade', id: g, income: increasedMoney }; } } else if (Game.UpgradesById[g].type == 'upgrade' && Game.UpgradesById[g].basePrice < moneyCanSpend && Game.UpgradesById[g].pool != 'toggle') { interest = Game.UpgradesById[g].basePrice / moneyCanSpend * 1000; if (typeof priorityListObj[Math.floor(interest)] === 'undefined') { priorityListObj[Math.floor(interest)] = { name: Game.UpgradesById[g].name, title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].basePrice), price: Game.UpgradesById[g].basePrice, cps: 1, type: 'upgrade', id: g, income: 0 }; } } //priorityList.push(Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].basePrice) + ' (INTEREST: ' + Beautify(interest) + ')'); } } for (var i in Game.ObjectsById) { if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) { if (Game.ObjectsById[i].locked === 0) { var cps = (Game.ObjectsById[i].storedTotalCps/Game.ObjectsById[i].amount) * Game.globalCpsMult; interest = Game.ObjectsById[i].price / cps; var pp = moneyCanSpend / Game.ObjectsById[i].price; // percent of cheapness if (pp > 50) interest /= pp * 50; priorityListObj[Math.floor(interest)] = { name: Game.ObjectsById[i].name, title: Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price), price: Game.ObjectsById[i].price, cps: cps, type: 'buy', id: i, income: cps }; //priorityList.push(Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price) + ' (INTEREST: ' + Beautify(interest) + ')'); } } } for (i in priorityListObj) { var prefix = priorityListObj[i].price < moneyCanSpend ? '!!! ' : (priorityListObj[i].price < money ? '! ' : ''); var pp = Math.floor(moneyCanSpend / priorityListObj[i].price * 100); priorityList.push(prefix + priorityListObj[i].title + ' : ' + i + ' (' + pp + '%)'); } timeCompensateObj = {}; timeCompensateList = []; for (i in priorityListObj) { var o = priorityListObj[i]; if (o.type == 'buy') { var cpsWithPercent = (o.cps / _getNormalCookiesPs() + 1) * o.cps; var interestNew = o.price / cpsWithPercent; timeCompensateObj[Math.floor(interestNew)] = { name: o.name, title: o.title, price: o.price, cps: cpsWithPercent, type: 'buy', id: o.id, income: o.income }; } else { timeCompensateObj[i] = o; } } for (i in timeCompensateObj) { prefix = timeCompensateObj[i].price < moneyCanSpend ? '!!! ' : (timeCompensateObj[i].price < money ? '! ' : ''); timeCompensateList.push(prefix + timeCompensateObj[i].title + ' : ' + i); } }; var _caption = function(txt) { var $v = jQuery('#versionNumber'); if ($v.text() != txt) $v.text(txt); }; var _title = function(txt) { var newTitle = (newLogs > 0 ? '(' + newLogs + ') ' : '') + txt; if (document.title != newTitle) { oldTitle = txt; document.title = newTitle; } }; var _titlePercent = function(have, need, txt) { var percent = Math.ceil(have / (need !== 0 ? need : 1) * 100); _title(String(percent) + "% - " + txt); }; var _logSectionTitle = function (text) { return '<div class="title">' + text + '</div>'; }; var _logSection = function (title, items) { return '<div class="subsection">' + _logSectionTitle(title) + '<div class="listing">' + items.join('</div><div class="listing">') + '</div>' + '</div>'; }; var clearLogButton = '<button data-id="clearLog" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">Clear Log</button>'; var _logPriorityTable = function() { var moneyCanSpend = _getMoneyCanSpend(); var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>'; 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>'; for (i in priorityListObj) { var o = priorityListObj[i]; var pp = Math.floor(moneyCanSpend / o.price * 100); 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>'; } t += '</table>'; return styles + '<div class="subsection">' + _logSectionTitle('Priority ' + clearLogButton) + '<div class="listing">' + t + '</div></div>'; } var _optionsSection = function() { var content = []; 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)" />'); content.push('<button data-id="showTimeCompensate" onclick="document.getElementById(\'logButton\').onbuttonclick(this,event)">showTimeCompensate: ' + (options.showTimeCompensate ? 'TRUE' : 'FALSE') + '</button>'); content.push(clearLogButton); return content; }; var _updateLog = function () { Game.updateLog = logTitle + //_logSection('Priority ' + clearLogButton, priorityList) + _logPriorityTable() + (options.showTimeCompensate ? _logSection('Priority (time compensate)', timeCompensateList) : '') + _logSection('Log', log) + _logSection('Options', _optionsSection()) + _logSection('History', _history()); var newButtonText = newLogs > 0 ? 'Log (' + newLogs + ')' : 'Log'; if (jQuery('#logButton').text() != newButtonText) jQuery('#logButton').text(newButtonText); _title(oldTitle); }; document.getElementById('logButton').onsliderchange = function(el) { var val = $(el).val(); _store('bankStoragePercent', val); options.bankStoragePercent = val; jQuery('#bankStoragePercentLabel').text('Storage (' + Beautify(_getMinimalMoney()) + ') percent: ' + val + '%'); _updateLog(); }; document.getElementById('logButton').onbuttonclick = function(el,e) { e.preventDefault(); var id = jQuery(el).attr('data-id'); if (id == 'showTimeCompensate') { options.showTimeCompensate = !options.showTimeCompensate; } else if (id == 'clearLog') { log = []; newLogs = 0; } jQuery(el).attr('disabled', 'disabled'); _updateLog(); } tPriority = setInterval(function () { _createPriorityList(); _updateLog(); }, 1000); var _addLog = function(text) { var t = new Date(); log.push(t.toUTCString() + ': ' + text); newLogs++; _updateLog(); }; tLog = setInterval(function () { _updateLog(); }, 600); jQuery('#logButton').text('Log').on("click", function() { newLogs = 0; jQuery('#logButton').text('Log'); }); var _getLongTimeUpgrade = function () { var moneyCanSpend = _getMoneyCanSpend(); var longTime = (Game.cookiesPs < 100) ? 1 : ( (Game.cookiesPs < 1000) ? 2 : ( (Game.cookiesPs < 10000) ? 3 : ( (Game.cookiesPs < 1E5) ? 4 : ( (Game.cookiesPs < 1E6) ? 5 : ( (Game.cookiesPs < 1E9) ? 10 : 15 ) ) ) ) ); return longTime; }; var _getWrinklerCount = function () { var wrinklersCount = 0; for (var i in Game.wrinklers) { if (Game.wrinklers[i].sucked > 0) { wrinklersCount++; } } return wrinklersCount; }; var _killAllWrinklers = function () { var wrinklersCount = _getWrinklerCount(); if (wrinklersCount >= 10 || Game.hasBuff('Elder frenzy')) { var wrinklesIncome = 0; for (var i in Game.wrinklers) { wrinklesIncome += Game.wrinklers[i].sucked; Game.wrinklers[i].hp = 0; // kill ALL } if (wrinklesIncome > 0) { _addLog('Killed all Wrinkles for ' + Beautify(wrinklesIncome) + ' because of ' + (Game.hasBuff('Elder frenzy') ? '"Elder frenzy"' : 'count 10.')); } } }; var _getMinimalPriceForNewObject = function () { var minNewObjectPrice = null; for (var i in Game.ObjectsById) { if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) { if (Game.ObjectsById[i].locked === 0 && Game.ObjectsById[i].amount === 0) { var p = Game.ObjectsById[i].price; if (minNewObjectPrice === null || p < minNewObjectPrice) minNewObjectPrice = p; } } } return minNewObjectPrice; }; var startT = function() { t2 = setInterval(function() { _killAllWrinklers(); var moneyCanSpend = _getMoneyCanSpend(); if (moneyCanSpend < 0) { var minimalMoney = _getMinimalMoney(); _caption('Collecting minimum ' + Beautify(minimalMoney)); _titlePercent(Game.cookies, minimalMoney, 'minimum'); return; } if (priorityList.length > 0) { for (var idx in priorityListObj) { var needToBuy = priorityListObj[idx]; if (needToBuy.type == 'upgrade') { _caption('Upgrading ' + needToBuy.name + ' for ' + Beautify(needToBuy.price)); if (needToBuy.price < moneyCanSpend) { if (Game.UpgradesById[needToBuy.id].canBuy()) { Game.UpgradesById[needToBuy.id].buy(); _addLog('Buy upgrade ' + Game.UpgradesById[needToBuy.id].name + ' for ' + Beautify(needToBuy.price)); _createPriorityList(); } } else { _titlePercent(moneyCanSpend, needToBuy.price, Game.UpgradesById[needToBuy.id].name); } } else { _caption('Collecting ' + Beautify(needToBuy.price) + ' for ' + needToBuy.name); if (Game.ObjectsById[needToBuy.id].price < moneyCanSpend) { Game.ObjectsById[needToBuy.id].buy(1); _addLog('Buy object ' + Game.ObjectsById[needToBuy.id].name + ' for ' + Beautify(Game.ObjectsById[needToBuy.id].price)); _createPriorityList(); } else { _titlePercent(moneyCanSpend, needToBuy.price, Game.ObjectsById[needToBuy.id].name); } } break; } return; } var minNewObjectPrice = _getMinimalPriceForNewObject(); var u = null; // upgrade can buy var minUpgradePrice = null; for (var g in Game.UpgradesById) { if (Game.UpgradesById[g].bought === 0 && Game.UpgradesById[g].unlocked == 1) { //u.push(Game.UpgradesById[g]); if (minUpgradePrice === null) { minUpgradePrice = Game.UpgradesById[g].basePrice; u = g; } else if (Game.UpgradesById[g].basePrice < minUpgradePrice) { minUpgradePrice = Game.UpgradesById[g].basePrice; u = g; } } } var longTime = _getLongTimeUpgrade(); var needUpgrade = (minNewObjectPrice > minUpgradePrice || minUpgradePrice === null) && u !== null && typeof Game.UpgradesById[u] !== 'undefined' && (moneyCanSpend >= minUpgradePrice || ((minUpgradePrice - moneyCanSpend) / _getNormalCookiesPs()) <= (longTime*60)); if (needUpgrade) { if (Game.UpgradesById[u].canBuy()) { Game.UpgradesById[u].buy(); _addLog('Buy upgrade ' + Game.UpgradesById[u].name + ' for ' + Beautify(minUpgradePrice)); } else { _caption('Upgrading ' + Game.UpgradesById[u].name + ' for ' + Beautify(minUpgradePrice)); _titlePercent(moneyCanSpend, minUpgradePrice, Game.UpgradesById[u].name); } } else { var minInvert = null, minObj = null; for (var i in Game.ObjectsById) { if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) { if (Game.ObjectsById[i].locked === 0) { var interest = Game.ObjectsById[i].price / Game.ObjectsById[i].storedCps; if (minInvert === null) { minInvert = interest; minObj = i; } else if (interest < minInvert) { minInvert = interest; minObj = i; } } } } if (minObj !== null) { if (Game.ObjectsById[minObj].price < moneyCanSpend) { Game.ObjectsById[minObj].buy(1); _addLog('Buy object ' + Game.ObjectsById[minObj].name + ' for ' + Beautify(Game.ObjectsById[minObj].price)); } else { _caption('Collecting ' + Beautify(Game.ObjectsById[minObj].price) + ' for ' + Game.ObjectsById[minObj].name); _titlePercent(moneyCanSpend, Game.ObjectsById[minObj].price, Game.ObjectsById[minObj].name); } } } }, 1000); started = true; _caption('Started'); _addLog('Autobuy start!'); }; var stopT = function() { clearInterval(t2); started = false; _caption('Collecting gold...'); _addLog('Autobuy stop.'); }; jQuery('#versionNumber').on("click", function() { if (!started) startT(); else stopT(); }); options.bankStoragePercent = _restore('bankStoragePercent'); if (typeof options.bankStoragePercent === 'undefined' || options.bankStoragePercent === null) { options.bankStoragePercent = 100; } setTimeout(function() { jQuery('#donateBox').hide(); t3 = setInterval(function() { var golden = Game.shimmers; if (golden.length > 0) { for (var i in golden) { golden[i].pop(); } } }, 500); tClickFrenzy = setInterval(function() { if (Game.hasBuff('Click frenzy') || Game.hasBuff('Cursed finger') || Game.cookiesPs < 1000000) { Game.ClickCookie(); } }, 75); if (Game.cookiesPs < 1E6) { tClick = setInterval(function() { Game.mouseX = jQuery('#bigCookie').width() / 2 + jQuery('#bigCookie').offset().left; Game.mouseY = jQuery('#bigCookie').height() / 2 + jQuery('#bigCookie').offset().top; Game.ClickCookie(); if (Game.cookiesPs > 1E8) clearInterval(tClick); }, 300); } _caption('Collecting gold...'); }, 5000); })();