1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-12-22 18:21:18 +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==
// @name Automate CookieClicker
// @namespace https://luzifer.io/
// @version 0.10.0
// @version 0.11.0
// @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me>
// @source https://github.com/Luzifer/automate-cookie-clicker
@ -36,17 +36,13 @@ function executeAutoActions() {
}
// Get the top enabled purchase to be made
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 < getMaxBuy()) {
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
let availableProducts = $('.product.unlocked.enabled').filter(productFilter);
if (availableProducts.length > 0) {
let product = availableProducts[availableProducts.length - 1];
debug("Auto-Buying: " + product.find('.title:first').text());
topPurchase.click();
note('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
}
note('Purchased ' + product.find('.title:first').text() + ' for you.');
}
}
@ -90,6 +86,11 @@ function note(msg, 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) {
var onClickHandler = $(this).attr('onclick');
if (onClickHandler == null) {