mirror of
https://github.com/Luzifer/automate-cookie-clicker.git
synced 2024-12-23 02:31:18 +00:00
Auto-Buy in single steps until 50 for all buildings
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
4ef349e695
commit
9a5b1adba5
1 changed files with 10 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Automate CookieClicker
|
// @name Automate CookieClicker
|
||||||
// @namespace https://luzifer.io/
|
// @namespace https://luzifer.io/
|
||||||
// @version 0.3.0
|
// @version 0.4.0
|
||||||
// @description Automate everything!
|
// @description Automate everything!
|
||||||
// @author Knut Ahlers <knut@ahlers.me>
|
// @author Knut Ahlers <knut@ahlers.me>
|
||||||
// @match http://orteil.dashnet.org/cookieclicker/
|
// @match http://orteil.dashnet.org/cookieclicker/
|
||||||
|
@ -19,9 +19,6 @@ function autoClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoPurchaseUpgrades() {
|
function autoPurchaseUpgrades() {
|
||||||
// Set buying amount to 10 per purchase
|
|
||||||
$('#storeBulk10').click();
|
|
||||||
|
|
||||||
// Look for upgrades being available
|
// Look for upgrades being available
|
||||||
let availableUpgrades = $('#upgrades > .upgrade.enabled');
|
let availableUpgrades = $('#upgrades > .upgrade.enabled');
|
||||||
if (availableUpgrades.length > 0) {
|
if (availableUpgrades.length > 0) {
|
||||||
|
@ -31,13 +28,15 @@ function autoPurchaseUpgrades() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the top enabled purchase to be made
|
// Get the top enabled purchase to be made
|
||||||
let topPurchase = $('.product.unlocked').last();
|
let topPurchase = $('.product.unlocked.enabled').last();
|
||||||
if (topPurchase.hasClass('enabled')) {
|
let topPurchaseCount = 0;
|
||||||
debug("Auto-Buying: " + topPurchase.find('.title').text());
|
if (topPurchase.find('.owned').text() != "") {
|
||||||
|
topPurchaseCount = parseInt(topPurchase.find('.owned').text());
|
||||||
|
}
|
||||||
|
if (topPurchaseCount < 50) {
|
||||||
|
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
|
||||||
topPurchase.click();
|
topPurchase.click();
|
||||||
toastr.info('Purchased ' + topPurchase.find('.title').text() + ' for you.');
|
toastr.info('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
|
||||||
} else {
|
|
||||||
debug("Not enough money to buy top purchase: " + topPurchase.find('.title').text() + " (need " + topPurchase.find('.price').text() + " cookies)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ function debug(msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable automatic purchasing of upgrades / elements
|
// Enable automatic purchasing of upgrades / elements
|
||||||
window.autoPurchase = window.setInterval(autoPurchaseUpgrades, 10000);
|
window.autoPurchase = window.setInterval(autoPurchaseUpgrades, 500);
|
||||||
|
|
||||||
// Startup notification
|
// Startup notification
|
||||||
let version = GM_info.script.version;
|
let version = GM_info.script.version;
|
||||||
|
|
Loading…
Reference in a new issue