Skip to content

Instantly share code, notes, and snippets.

@spaetzel
Forked from dieseltravis/cookiebot.js
Last active December 24, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spaetzel/6727992 to your computer and use it in GitHub Desktop.
Save spaetzel/6727992 to your computer and use it in GitHub Desktop.
Attempt to get clicking on only items needed for achievements to work.
CookieBot = {
start: function() {
//TODO: limit this to 15 for hidden achievement?
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!
Game.goldenCookie.delay=1;
$("#goldenCookie").click();
/*
var $g = $("#goldenCookie");
try{
// Don't click angry grandmas' wrath cookies
if (!/wrath/.test($g[0].style.background)) {
$g.click();
}
}catch(ex){}
// Now we need to buy stuff with our money.
// Start by trying to buy the most-expensive item
var products = [].slice.call($$(".product.enabled")).reverse();
console.log( products, products.length );
if (products.length > 0) {
// don't buy more than needed for achievements
for (var i = 0; i < products.length; i++) {
var last = products[i];
var max = 128;
console.log( $(".owned", last).innnerHTML, max);
var owned = parseInt($(".owned", last).text(), 10);
if (owned < max) {
last.click();
//break();
}
}
} else {
// Then try to buy the most expensive upgrade
try{
var upgrade = [].slice.call($$(".upgrade.enabled")).reverse()[0];
if (upgrade) {
upgrade.click();
}
}catch(ex){}
} */
}, 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