From 6a19e97ccb756c923459882b87a2aaa6825fe986 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 21 Apr 2018 12:29:58 +0200 Subject: [PATCH] Do upgrades through Game object instead of interface Signed-off-by: Knut Ahlers --- autocookieclicker.user.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/autocookieclicker.user.js b/autocookieclicker.user.js index a8ee739..2bcdc90 100644 --- a/autocookieclicker.user.js +++ b/autocookieclicker.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Automate CookieClicker // @namespace https://luzifer.io/ -// @version 0.18.2 +// @version 0.18.3 // @description Automate everything! // @author Knut Ahlers // @source https://github.com/Luzifer/automate-cookie-clicker @@ -43,10 +43,11 @@ function executeAutoActions() { } // Look for upgrades being available - let availableUpgrades = $('.upgrade.enabled').filter(upgradeFilter); - if (availableUpgrades.length > 0) { - availableUpgrades.click(); - note('Purchased ' + availableUpgrades.length + ' upgrades for you.'); + let availableUpgrades = Game.UpgradesInStore.filter(obj => obj.canBuy() && !blockingUpgrades.includes(obj.id)); + while (availableUpgrades.length > 0) { + let upgrade = availableUpgrades[0]; + upgrade.buy(); + note('Purchased upgrade ' + upgrade.name + ' for you.'); } // Get the top enabled purchase to be made @@ -123,15 +124,6 @@ function note(msg, quick = true) { Game.Notify('Auto-CookieClicker', msg, [12, 0], quick, true); } -function upgradeFilter() { - let onClickHandler = $(this).attr('onclick'); - if (onClickHandler == null) { - return false; - } - let upgradeID = parseInt(onClickHandler.replace(/^.*\[([0-9]+)\].*$/, '$1')); - return !blockingUpgrades.includes(upgradeID); -} - (function() { 'use strict';