Cheating at Cookie Clicker

Multithreaded JavaScript has been published with O'Reilly!

A friend linked to this game the other day:

Cookie Clicker

It's really simple. You click something over and over, and you buy upgrades, and then some automated processes happen in the background.

Open your console, and paste in the following commands. They will allow you to play the game automatically. Notice the $$; this uses MooTools, not jQuery.

// Automatically purchase new products (e.g. Grandmas) each second as they become available
setInterval(function() { $$('.product.enabled')[0].click(); }, 1000);

// Automatically click the big cookie 10 times per second
setInterval(function() {$('#bigCookie').click();}, 100);

// Automatically purchase upgrades each second as they become available
setInterval(function() { $$('.upgrade.enabled')[0].click(); }, 1000);

These simple commands don't play the game as efficiently as possible. One could graph out the best way to play the game, which would involve saving up for better options instead of always spending money.

For Cookie Clicker to prevent this easy way of cheating the game, they'd probably want to not load MooTools as a global object, and randomize the names of DOM elements each time the game is loaded. Those wouldn't prevent these cheats 100%, but it would make them harder to perform.

Tags: #javascript
Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript and is an O'Reilly published author.