1
0
Fork 0
mirror of https://github.com/Luzifer/automate-cookie-clicker.git synced 2024-12-23 02:31:18 +00:00

Show notifications for actions done

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-02-12 00:07:39 +01:00
parent 3d3e9e695d
commit 4ef349e695
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -1,16 +1,22 @@
// ==UserScript== // ==UserScript==
// @name Automate CookieClicker // @name Automate CookieClicker
// @namespace https://luzifer.io/ // @namespace https://luzifer.io/
// @version 0.2.1 // @version 0.3.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/
// @run-at document-start
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js // @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 // @updateURL https://gist.github.com/Luzifer/706ea5db3e0a65f1dd142d7afa3aecb0/raw/autocookieclicker.user.js
// @grant GM_info
// @grant GM_addStyle
// ==/UserScript== // ==/UserScript==
function autoClick() { $('#bigCookie').click(); } GM_addStyle('@import url("https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css");');
function autoClick() {
$('#bigCookie').click();
}
function autoPurchaseUpgrades() { function autoPurchaseUpgrades() {
// Set buying amount to 10 per purchase // Set buying amount to 10 per purchase
@ -21,6 +27,7 @@ function autoPurchaseUpgrades() {
if (availableUpgrades.length > 0) { if (availableUpgrades.length > 0) {
debug(availableUpgrades.length + " upgrades available, buying now..."); debug(availableUpgrades.length + " upgrades available, buying now...");
availableUpgrades.click(); availableUpgrades.click();
toastr.info('Purchased ' + availableUpgrades.length + ' upgrades for you.');
} }
// Get the top enabled purchase to be made // Get the top enabled purchase to be made
@ -28,6 +35,7 @@ function autoPurchaseUpgrades() {
if (topPurchase.hasClass('enabled')) { if (topPurchase.hasClass('enabled')) {
debug("Auto-Buying: " + topPurchase.find('.title').text()); debug("Auto-Buying: " + topPurchase.find('.title').text());
topPurchase.click(); topPurchase.click();
toastr.info('Purchased ' + topPurchase.find('.title').text() + ' for you.');
} else { } else {
debug("Not enough money to buy top purchase: " + topPurchase.find('.title').text() + " (need " + topPurchase.find('.price').text() + " cookies)"); debug("Not enough money to buy top purchase: " + topPurchase.find('.title').text() + " (need " + topPurchase.find('.price').text() + " cookies)");
} }
@ -40,6 +48,25 @@ function debug(msg) {
(function() { (function() {
'use strict'; '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]); let cps = parseInt($('#cookies').children('div').text().split(': ')[1]);
if (cps == 0) { if (cps == 0) {
window.autoClicker = window.setInterval(autoClick, 1); window.autoClicker = window.setInterval(autoClick, 1);
@ -47,4 +74,8 @@ 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, 10000);
// Startup notification
let version = GM_info.script.version;
toastr.info('Auto-CookieClicker ' + version + ' loaded.');
})(); })();