From d9877b6413967b71047df4d0bb1486ef95ec829a Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 12 Feb 2018 20:22:54 +0100 Subject: [PATCH] Track CPS and handle script clicking Signed-off-by: Knut Ahlers --- autocookieclicker.user.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/autocookieclicker.user.js b/autocookieclicker.user.js index bc9537b..b47b9ef 100644 --- a/autocookieclicker.user.js +++ b/autocookieclicker.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Automate CookieClicker // @namespace https://luzifer.io/ -// @version 0.4.0 +// @version 0.5.0 // @description Automate everything! // @author Knut Ahlers // @match http://orteil.dashnet.org/cookieclicker/ @@ -40,6 +40,18 @@ function autoPurchaseUpgrades() { } } +function checkCPS() { + let cps = parseInt($('#cookies').children('div').text().split(': ')[1]); + if (cps < 3000 && window.autoClicker == undefined) { + window.autoClicker = window.setInterval(autoClick, 1); + } else { + if (window.autoClicker != undefined) { + window.clearInterval(window.autoClicker); + window.autoClicker = undefined; + } + } +} + function debug(msg) { console.log("[AutoCookieClicker] " + msg); } @@ -66,10 +78,7 @@ function debug(msg) { "hideMethod": "fadeOut" }; - let cps = parseInt($('#cookies').children('div').text().split(': ')[1]); - if (cps == 0) { - window.autoClicker = window.setInterval(autoClick, 1); - } + window.checkCPS = window.setInterval(checkCPS, 1000); // Enable automatic purchasing of upgrades / elements window.autoPurchase = window.setInterval(autoPurchaseUpgrades, 500);