1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-11-08 14:00:12 +00:00

Do not try to buy when there is nothing to buy

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-03-02 22:50:07 +01:00
parent f489079569
commit 447bc7d2d1
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name Automate CookieClicker
// @namespace https://luzifer.io/
// @version 0.5.1
// @version 0.5.2
// @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me>
// @match http://orteil.dashnet.org/cookieclicker/
@ -28,15 +28,17 @@ function autoPurchaseUpgrades() {
}
// Get the top enabled purchase to be made
let topPurchase = $('.product.unlocked.enabled').last();
let topPurchaseCount = 0;
if (topPurchase.find('.owned').text() != "") {
topPurchaseCount = parseInt(topPurchase.find('.owned').text());
}
if (topPurchaseCount < 50) {
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
topPurchase.click();
toastr.info('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
if ($('.product.unlocked.enabled').length > 0) {
let topPurchase = $('.product.unlocked.enabled').last();
let topPurchaseCount = 0;
if (topPurchase.find('.owned').text() != "") {
topPurchaseCount = parseInt(topPurchase.find('.owned').text());
}
if (topPurchaseCount < 50) {
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
topPurchase.click();
toastr.info('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
}
}
}