mirror of
https://github.com/Luzifer/automate-cookie-clicker.git
synced 2024-12-23 02:31:18 +00:00
Use a dynamic maximum
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
447bc7d2d1
commit
4de087373a
1 changed files with 18 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Automate CookieClicker
|
// @name Automate CookieClicker
|
||||||
// @namespace https://luzifer.io/
|
// @namespace https://luzifer.io/
|
||||||
// @version 0.5.2
|
// @version 0.6.0
|
||||||
// @description Automate everything!
|
// @description Automate everything!
|
||||||
// @author Knut Ahlers <knut@ahlers.me>
|
// @author Knut Ahlers <knut@ahlers.me>
|
||||||
// @match http://orteil.dashnet.org/cookieclicker/
|
// @match http://orteil.dashnet.org/cookieclicker/
|
||||||
|
@ -34,7 +34,7 @@ function autoPurchaseUpgrades() {
|
||||||
if (topPurchase.find('.owned').text() != "") {
|
if (topPurchase.find('.owned').text() != "") {
|
||||||
topPurchaseCount = parseInt(topPurchase.find('.owned').text());
|
topPurchaseCount = parseInt(topPurchase.find('.owned').text());
|
||||||
}
|
}
|
||||||
if (topPurchaseCount < 50) {
|
if (topPurchaseCount < getMaxBuy()) {
|
||||||
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
|
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
|
||||||
topPurchase.click();
|
topPurchase.click();
|
||||||
toastr.info('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
|
toastr.info('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
|
||||||
|
@ -60,6 +60,22 @@ function debug(msg) {
|
||||||
console.log("[AutoCookieClicker] " + msg);
|
console.log("[AutoCookieClicker] " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMaxBuy() {
|
||||||
|
var topPurchaseCount = 0;
|
||||||
|
var topPurchaseTextCount = $('#product14').find('.owned').text();
|
||||||
|
if (topPurchaseTextCount != "") {
|
||||||
|
topPurchaseCount = parseInt(topPurchaseTextCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = Math.max(Math.ceil(topPurchaseCount / 50), 1) * 50;
|
||||||
|
if (topPurchaseCount == max) {
|
||||||
|
// Special case: Cap was already bought
|
||||||
|
max += 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue