Skip to content

Instantly share code, notes, and snippets.

@aphexddb
Created September 5, 2013 15:28
Show Gist options
  • Save aphexddb/6451730 to your computer and use it in GitHub Desktop.
Save aphexddb/6451730 to your computer and use it in GitHub Desktop.

Cookie Clicker cheats

http://orteil.dashnet.org/cookieclicker/

Usage

The recommended way to use these cheats is by using the bookmarklets: copy the bookmarklet code, then create a new bookmark using the code as the URL. You can simply click the bookmarks to activate (or deactivate) the cheats. For cheats that don't have an accompanying disable cheat, you have to reload the page to disable them.

Alternatively, you could insert the code into Firebug (all browsers) or WebKit (Chrome, Safari) console, or add it as a user script. If you decide to add it as a user script, you'll probably want to use the unminified code so that you can modify it easily.

Note: These cheats are not 100% tested. Report any issues in the comments.

Disable auto-clicker detection

The game is able to detect auto-clickers by measuring the click speed. This is easy to work around, however it's not required for my auto-clicker cheat, as it's written in JavaScript, bypassing that detection.

Code

(function () {
    document.getElementById('bigCookie').onClick = function () {
        Game.Earn(Game.computedMouseCps);
        Game.handmadeCookies += Game.computedMouseCps;

        if (Game.prefs.particles) {
            Game.cookieParticleAdd();
        }

        if (Game.prefs.numbers) {
            Game.cookieNumberAdd('+' + Beautify(Game.computedMouseCps, 1));
            ++Game.cookieClicks;
        }

        Game.lastClick = new Date().getTime();
    };

    alert('Cheat "Disable auto-clicker detection" enabled!');
}());

Bookmarklet

javascript:(function(G){document.getElementById('bigCookie').onClick=function(){G.Earn(Game.computedMouseCps);G.handmadeCookies+=G.computedMouseCps;if(G.prefs.particles){G.cookieParticleAdd();}if(G.prefs.numbers){G.cookieNumberAdd('+'+Beautify(G.computedMouseCps,1));++G.cookieClicks;}Game.lastClick=new Date().getTime();};alert('Cheat "Disable auto-clicker detection" enabled!');}(Game));

Auto-clicker (enable)

This is a convenient auto-clicker implemented in JavaScript, which means you can do other things while letting this run. The interval is specified in milliseconds (1000 ms = 1 s).

WARNING: If you happen to run this cheat more than once, you have to reload the page to completely disable it.

Code

(function () {
    var interval = prompt('Enter interval in milliseconds (1000 ms = 1 s)');

    window.autoClicker = setInterval(function () {
        ++Game.cookies;
        ++Game.cookiesEarned;
        ++Game.handmadeCookies;
        ++Game.cookiesClicked;
    }, interval);

    alert('Cheat "Auto-clicker" enabled!');
}());

Bookmarklet

javascript:(function(G){var v=prompt('Enter interval in milliseconds (1000 ms = 1 s)');G.autoClicker=setInterval(function(){++G.cookies;++G.cookiesEarned;++G.handmadeCookies;++G.cookiesClicked;},v);alert('Cheat "Auto-clicker" enabled!');}(Game));

Auto-clicker (disable)

Code

(function () {
    if (window.autoClicker !== undefined) {
        clearInterval(window.autoClicker);
        window.autoClicker = undefined;
        alert('Cheat "Auto-clicker" disabled!');
    } else {
        alert('Cheat "Auto-clicker" wasn\'t enabled.');
    }
}());

Bookmarklet

javascript:(function(w){if(w.autoClicker!==undefined){clearInterval(w.autoClicker);w.autoClicker=undefined;alert('Cheat "Auto-clicker" disabled!');}else{alert('Cheat "Auto-clicker" wasn\'t enabled.');}}(window));

Auto-buy (enable)

This will automatically buy items from the store as soon as they are available (checked every second). You can also set a threshold to stop buying items after you have a specific amount or more of them.

TODO: Add an option to prefer buying items that you have more of.

WARNING: If you happen to run this cheat more than once, you have to reload the page to completely disable it.

Code

(function () {
    var objects, threshold, i;

    objects = ['Cursor', 'Grandma', 'Farm', 'Factory', 'Mine', 'Shipment', 'Alchemy lab', 'Portal', 'Time machine'];
    threshold = parseInt(prompt('Enter threshold for item count'));

    if (isNaN(threshold)) {
        alert('Error: Invalid input.');
        return false;
    }

    window.autoBuy = setInterval(function () {
        for (i in objects) {
            var object = objects[i],
                objref = Game.Objects[object];

            if (objref !== undefined && objref.amount < threshold && Game.cookies >= objref.price) {
                objref.buy();
            }
        }
    }, 1000);

    alert('Cheat "Auto-buy" enabled! Threshold: ' + threshold);
}());

Bookmarklet

javascript:(function(G){var O,t,i;O=['Cursor','Grandma','Farm','Factory','Mine','Shipment','Alchemy lab','Portal','Time machine'];t=parseInt(prompt('Enter threshold for item count'));if(isNaN(t)){alert('Error: Invalid input.');return false;};window.autoBuy=setInterval(function(){for(i in O){var o=O[i],r=G.Objects[o];if(r!==undefined&&r.amount<t&&G.cookies>=r.price){r.buy();}}},1000);alert('Cheat "Auto-buy" enabled! Threshold: '+t);}(Game));

Auto-buy (disable)

Code

(function () {
    if (window.autoBuy !== undefined) {
        clearInterval(window.autoBuy);
        window.autoBuy = undefined;
        alert('Cheat "Auto-buy" disabled!');
    } else {
        alert('Cheat "Auto-buy" wasn\'t enabled.');
    }
}());

Bookmarklet

javascript:(function(w){if(w.autoBuy!==undefined){clearInterval(w.autoBuy);w.autoBuy=undefined;alert('Cheat "Auto-buy" disabled!');}else{alert('Cheat "Auto-buy" wasn\'t enabled.');}}(window));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment