Skip to content

Instantly share code, notes, and snippets.

@607011
Last active July 6, 2018 15:16
Show Gist options
  • Save 607011/db91ae37170b66f2d339bf64399b0e48 to your computer and use it in GitHub Desktop.
Save 607011/db91ae37170b66f2d339bf64399b0e48 to your computer and use it in GitHub Desktop.
Cookie Clicker Click Agent
// ==UserScript==
// @name Cookie Clicker Click Agent
// @description Never again miss a golden cookie or sugar lump. Improve cookie production by automatically clicking the big cookie.
// @version 1
// @namespace *
// @include http://orteil.dashnet.org/cookieclicker/
// @grant none
// ==/UserScript==
/* DISCLAIMER
* ==========
*
* Cheating is morally reprehensible. But you're only deceiving
* yourself in this game, and nobody else. That's why this
* tiny script may be okay.
*
*/
const BigCookieClicksPerSecond = 20;
const GoldenCookieCheckIntervalMS = 2500;
const SugarLumpCheckIntervalMins = 15;
const MinGoldenCookieOpacity = .98;
const VERBOSE = true;
let bigCookie = document.getElementById('bigCookie');
setInterval(() => {
bigCookie.click();
}, 1000 / BigCookieClicksPerSecond);
let shimmerContainer = document.getElementById('shimmers');
let shimmerDetected = [false];
setInterval(() => {
let shimmers = Array.from(shimmerContainer.getElementsByClassName('shimmer'));
let tryClick = (shimmer, idx) => {
if (getComputedStyle(shimmer).opacity > MinGoldenCookieOpacity) {
shimmer.click();
shimmerDetected[idx] = false;
if (VERBOSE)
console.log((new Date()).toISOString(), idx, shimmer, "CLICKED.");
}
else {
setTimeout(() => { tryClick(shimmer, idx); }, 250);
}
};
shimmers.forEach((shimmer, idx) => {
if (!shimmerDetected[idx]) {
if (VERBOSE)
console.log((new Date()).toISOString(), idx, shimmer, "DETECTED.");
shimmerDetected[idx] = true;
tryClick(shimmer, idx);
}
});
}, GoldenCookieCheckIntervalMS);
setInterval(() => {
Game.clickLump();
}, 60 * 1000 * SugarLumpCheckIntervalMins);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment