Skip to content

Instantly share code, notes, and snippets.

@jdewind
Last active December 24, 2015 02:09
Show Gist options
  • Save jdewind/6728196 to your computer and use it in GitHub Desktop.
Save jdewind/6728196 to your computer and use it in GitHub Desktop.
CookieBot = {
start: function() {
this.clickInterval = setInterval(function(){
// Click the large cook as fast as possible!
$("#bigCookie").click();
}, 1);
this.goldenCookieInterval = setInterval(function() {
Game.goldenCookie.delay = 0;
});
this.buyInterval = setInterval(function(){
// Sometimes a golden cookie will appear to give you a bonus
// Click that too!
$("#goldenCookie").click();
}, 1000);
},
stop: function() {
clearInterval(this.goldenCookieInterval);
clearInterval(this.clickInterval);
clearInterval(this.buyInterval);
}
};
CookieBot = {
start: function() {
this.clickInterval = setInterval(function(){
// Click the large cook as fast as possible!
$("#bigCookie").click();
}, 1);
this.buyInterval = setInterval(function(){
// Sometimes a golden cookie will appear to give you a bonus
// Click that too!
$("#goldenCookie").click();
// Now we need to buy stuff with our money.
// Start by trying to buy the most-expensive item
var last = [].slice.call($$(".product.enabled")).reverse()[0];
if (last) {
last.click();
} else {
// Then try to buy the most expensive upgrade
var upgrade = [].slice.call($$(".upgrade.enabled")).reverse()[0];
if (upgrade && !(/\[85\]/.test(upgrade.onclick.toString()))) {
upgrade.click();
}
}
}, 1000);
},
stop: function() {
clearInterval(this.clickInterval);
clearInterval(this.buyInterval);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment