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

Also purchase for non top products

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-04-14 21:12:59 +02:00
parent ca590a990a
commit 17ea39c49e
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Automate CookieClicker // @name Automate CookieClicker
// @namespace https://luzifer.io/ // @namespace https://luzifer.io/
// @version 0.10.0 // @version 0.11.0
// @description Automate everything! // @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me> // @author Knut Ahlers <knut@ahlers.me>
// @source https://github.com/Luzifer/automate-cookie-clicker // @source https://github.com/Luzifer/automate-cookie-clicker
@ -36,17 +36,13 @@ function executeAutoActions() {
} }
// Get the top enabled purchase to be made // Get the top enabled purchase to be made
if ($('.product.unlocked.enabled').length > 0) { let availableProducts = $('.product.unlocked.enabled').filter(productFilter);
let topPurchase = $('.product.unlocked.enabled').last(); if (availableProducts.length > 0) {
let topPurchaseCount = 0; let product = availableProducts[availableProducts.length - 1];
if (topPurchase.find('.owned').text() != "") {
topPurchaseCount = parseInt(topPurchase.find('.owned').text()); debug("Auto-Buying: " + product.find('.title:first').text());
} topPurchase.click();
if (topPurchaseCount < getMaxBuy()) { note('Purchased ' + product.find('.title:first').text() + ' for you.');
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
topPurchase.click();
note('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
}
} }
} }
@ -90,6 +86,11 @@ function note(msg, quick = true) {
Game.Notify("Auto-CookieClicker", msg, [12, 0], quick, true); Game.Notify("Auto-CookieClicker", msg, [12, 0], quick, true);
} }
function productFilter(idx) {
let owned = Game.ObjectsById[parseInt($(this).attr('id').replace(/^product/, ''))].amount;
return owned < getMaxBuy();
}
function upgradeFilter(idx) { function upgradeFilter(idx) {
var onClickHandler = $(this).attr('onclick'); var onClickHandler = $(this).attr('onclick');
if (onClickHandler == null) { if (onClickHandler == null) {