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:
parent
ca590a990a
commit
17ea39c49e
1 changed files with 13 additions and 12 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue