1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-11-08 22:10:09 +00:00
This commit is contained in:
Knut Ahlers 2018-02-11 23:43:56 +01:00 committed by GitHub
commit 3724cc65bd

49
user.js Normal file
View file

@ -0,0 +1,49 @@
// ==UserScript==
// @name Automate CookieClicker
// @namespace https://luzifer.io/
// @version 0.1
// @description Automate everything!
// @author Knut Ahlers <knut@ahlers.me>
// @match http://orteil.dashnet.org/cookieclicker/
// @run-at document-start
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
// ==/UserScript==
function autoClick() { $('#bigCookie').click(); }
function autoPurchaseUpgrades() {
// Set buying amount to 10 per purchase
$('#storeBulk10').click();
// Look for upgrades being available
let availableUpgrades = $('#upgrades > .upgrade.enabled');
if (availableUpgrades.length > 0) {
debug(availableUpgrades.length + " upgrades available, buying now...");
availableUpgrades.click();
}
// Get the top enabled purchase to be made
let topPurchase = $('.product.unlocked').last();
if (topPurchase.hasClass('enabled')) {
debug("Auto-Buying: " + topPurchase.find('.title').text());
topPurchase.click();
} else {
debug("Not enough money to buy top purchase: " + topPurchase.find('.title').text() + " (need " + topPurchase.find('.price').text() + " cookies)");
}
}
function debug(msg) {
console.log("[AutoCookieClicker] " + msg);
}
(function() {
'use strict';
let cps = parseInt($('#cookies').children('div').text().split(': ')[1]);
if (cps == 0) {
window.autoClicker = window.setInterval(autoClick, 1);
}
// Enable automatic purchasing of upgrades / elements
window.autoPurchase = window.setInterval(autoPurchaseUpgrades, 10000);
})();