2018-02-11 22:43:56 +00:00
|
|
|
// ==UserScript==
|
2018-02-11 23:07:39 +00:00
|
|
|
// @name Automate CookieClicker
|
|
|
|
// @namespace https://luzifer.io/
|
2018-02-12 18:57:57 +00:00
|
|
|
// @version 0.4.0
|
2018-02-11 23:07:39 +00:00
|
|
|
// @description Automate everything!
|
|
|
|
// @author Knut Ahlers <knut@ahlers.me>
|
|
|
|
// @match http://orteil.dashnet.org/cookieclicker/
|
|
|
|
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js
|
|
|
|
// @require https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js
|
|
|
|
// @updateURL https://gist.github.com/Luzifer/706ea5db3e0a65f1dd142d7afa3aecb0/raw/autocookieclicker.user.js
|
|
|
|
// @grant GM_info
|
|
|
|
// @grant GM_addStyle
|
2018-02-11 22:43:56 +00:00
|
|
|
// ==/UserScript==
|
|
|
|
|
2018-02-11 23:07:39 +00:00
|
|
|
GM_addStyle('@import url("https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css");');
|
|
|
|
|
|
|
|
function autoClick() {
|
|
|
|
$('#bigCookie').click();
|
|
|
|
}
|
2018-02-11 22:43:56 +00:00
|
|
|
|
|
|
|
function autoPurchaseUpgrades() {
|
2018-02-11 23:07:39 +00:00
|
|
|
// Look for upgrades being available
|
|
|
|
let availableUpgrades = $('#upgrades > .upgrade.enabled');
|
|
|
|
if (availableUpgrades.length > 0) {
|
|
|
|
debug(availableUpgrades.length + " upgrades available, buying now...");
|
|
|
|
availableUpgrades.click();
|
|
|
|
toastr.info('Purchased ' + availableUpgrades.length + ' upgrades for you.');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the top enabled purchase to be made
|
2018-02-12 18:57:57 +00:00
|
|
|
let topPurchase = $('.product.unlocked.enabled').last();
|
|
|
|
let topPurchaseCount = 0;
|
|
|
|
if (topPurchase.find('.owned').text() != "") {
|
|
|
|
topPurchaseCount = parseInt(topPurchase.find('.owned').text());
|
|
|
|
}
|
|
|
|
if (topPurchaseCount < 50) {
|
|
|
|
debug("Auto-Buying: " + topPurchase.find('.title:first').text());
|
2018-02-11 23:07:39 +00:00
|
|
|
topPurchase.click();
|
2018-02-12 18:57:57 +00:00
|
|
|
toastr.info('Purchased ' + topPurchase.find('.title:first').text() + ' for you.');
|
2018-02-11 23:07:39 +00:00
|
|
|
}
|
2018-02-11 22:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function debug(msg) {
|
2018-02-11 23:07:39 +00:00
|
|
|
console.log("[AutoCookieClicker] " + msg);
|
2018-02-11 22:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(function() {
|
2018-02-11 23:07:39 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Set options for toastr
|
|
|
|
toastr.options = {
|
|
|
|
"closeButton": false,
|
|
|
|
"debug": false,
|
|
|
|
"newestOnTop": false,
|
|
|
|
"progressBar": false,
|
|
|
|
"positionClass": "toast-bottom-right",
|
|
|
|
"preventDuplicates": false,
|
|
|
|
"onclick": null,
|
|
|
|
"showDuration": "300",
|
|
|
|
"hideDuration": "1000",
|
|
|
|
"timeOut": "2000",
|
|
|
|
"extendedTimeOut": "1000",
|
|
|
|
"showEasing": "swing",
|
|
|
|
"hideEasing": "linear",
|
|
|
|
"showMethod": "fadeIn",
|
|
|
|
"hideMethod": "fadeOut"
|
|
|
|
};
|
|
|
|
|
|
|
|
let cps = parseInt($('#cookies').children('div').text().split(': ')[1]);
|
|
|
|
if (cps == 0) {
|
|
|
|
window.autoClicker = window.setInterval(autoClick, 1);
|
|
|
|
}
|
2018-02-11 22:43:56 +00:00
|
|
|
|
2018-02-11 23:07:39 +00:00
|
|
|
// Enable automatic purchasing of upgrades / elements
|
2018-02-12 18:57:57 +00:00
|
|
|
window.autoPurchase = window.setInterval(autoPurchaseUpgrades, 500);
|
2018-02-11 22:43:56 +00:00
|
|
|
|
2018-02-11 23:07:39 +00:00
|
|
|
// Startup notification
|
|
|
|
let version = GM_info.script.version;
|
|
|
|
toastr.info('Auto-CookieClicker ' + version + ' loaded.');
|
|
|
|
})();
|