Skip to content

Instantly share code, notes, and snippets.

@triktron
Created June 16, 2019 16:12
Show Gist options
  • Save triktron/df169d3d05e6d9ceeea5349e390afbe3 to your computer and use it in GitHub Desktop.
Save triktron/df169d3d05e6d9ceeea5349e390afbe3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Cookie Clicker auto buying script
// @version 0.1
// @description this scrip will calculate what the best building to buy is, and then buy it. it also buys your upgrades and clicks golden cookies.
// @author Triktron
// @match https://orteil.dashnet.org/cookieclicker/
// @grant none
// ==/UserScript==
function IsReady() {
if (Game && Game.ready == 1) startAutoBuy(); else setTimeout(IsReady, 200);
}
IsReady();
function startAutoBuy() {
Game.Notify("Auto buy", "Starting...");
var autoBuy = setInterval(function test(){
var note = Game.Notes.find(n => n.title == "Auto buy");
if (!note) {clearInterval(autoBuy); return;}
if (Game.UpgradesInStore[0] && Game.UpgradesInStore[0].getPrice() < Game.cookies) Game.UpgradesInStore[0].buy();
var buildings = Game.ObjectsById.map(building => ({id: building.id, price: building.getPrice(), cps: building.cps(building)}));
var best = Game.ObjectsById[buildings.sort(function(a,b){return a.price*(a.cps+Game.unbuffedCps)/a.cps-b.price*(b.cps+Game.unbuffedCps)/b.cps})[0].id];
if (best.price < Game.cookies) {best.buy();note.desc = "just bought " + best.name;} else note.desc = "saving up for the " + best.name + " and need " + Beautify(best.price - Game.cookies) + " to buy it";
note.life = 999;
Game.UpdateNotes()
Game.shimmers.forEach(function(shimmer){if(shimmer.type == "golden" && shimmer.wrath == 0){shimmer.pop()}})
}, 500);
}
@triktron
Copy link
Author

i don't know why i made this.... i just... felt like making it... XD feel free to try it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment