Skip to content
← Back to Community
Cookie Clicker in JavaScript
Profile icon
NoelB33

So, I decided to make a cookie clicker. It’s not very good yet, but this was the first project I made after learning a bit of JavaScript. If you have any suggestions on how I can make this better, please tell me! Also, it saves data! That was probably the part I spent the most time on.

Voters
Profile icon
JohnAnderson18
Profile icon
lycanroc441
Profile icon
lexili
Profile icon
Kopamed
Profile icon
CodingGoose
Profile icon
BobNeo
Profile icon
AgastyaSandhuja
Profile icon
BobTheTomatoPie
Profile icon
AmazingMech2418
Profile icon
DeBeast591
Comments
hotnewtop
Profile icon
ChezCoder

I created exploit. Just paste this in console.

try{var x;function hax(){x=setInterval(ClickUp)} function stopHax(){clearInterval(x)} function setCookies(intPlz){clicks=intPlz} function addCookies(intPlz){clicks+=intPlz-1} setInterval(()=>{if(clicks==Infinity){clicks=1e+100;console.log("Oops! Looks like the amount of cookies reached infinity! Don't worry, I have set it back to 1e+100.");}});console.log("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\Successfull Injection.");}catch{console.log("Oops! Looks like there was an issue. Please contact chez!")}

To start hax, type hax() in console.
To stop hax, type stopHax() in console.

Have fun!

Edit: @NoelBryan pointed a might be a problem problem so I updated the above just in case it doesn't save. :D

Also I added 2 new funcs:

To set the cookies, do setCookies(--THE NUMBER OF COOKIES--)
To add to the cookies, do addCookies(--THE NUMBER OF COOKIES--)

Have fun!

x2

DOCUMENTATION:

hax() - Adds like a million cookies every second
stopHax() - Stops the hax above.
setCookies(--COOKIES--) - Sets the cookies to the amount specified.
addCookies(--COOKIES--) - Adds the cookies to the current amount you have.

__ NEW! __ Now with auto infinity correction! - Automatically sets the amount of cookies to 1e+100 if the cookies suddenly reach infinity.

Profile icon
NoelB33

But that won’t save your data unless you click on the cookie also. @ChezCoder
Edit: wait it will dang it
Edit2: but it won’t work for people on mobile

Profile icon
NoelB33

I think I patched it! @ChezCoder

Profile icon
ChezCoder

@NoelBryan nope, just tested it XD

Profile icon
NoelB33

I tried to do this:
function hax(){
alert(‘You tried to use ChezCoder’s hax didn’t you?’)
}
But it didn’t work.
I can’t think of any other way to stop this lol
@ChezCoder

Profile icon
ChezCoder

@NoelBryan thats cuz my hax redefines the function hax(). Its like you declare the variable x. But my script re-declares it or "changes the script" for the function.

Profile icon
NoelB33

Ohhhhhh, dang it. @ChezCoder

Profile icon
ChezCoder
Profile icon
NoelB33

I’ll overwrite your function lol in the game @ChezCoder

Profile icon
NoelB33

I’m trying to overwrite the function every second but it’s not working @ChezCoder

Profile icon
ChezCoder

@NoelBryan a way to patch it is to change the variables and function names so that my code wont match yours. But I can just change it to what you changed your variables and functions to. This isn't really a patch but rather something annoying for exploiters.

Profile icon
NoelB33
Profile icon
ChezCoder

@NoelBryan i have infinity cookies....

Profile icon
NoelB33

Noooooooooooooo I failed @ChezCoder

Profile icon
ChezCoder

@NoelBryan lol i can't buy anothing now... also to change the variables, you can do find and replace with ctrl + f or cmd + f for mac

Profile icon
NoelB33

Wait you actually can’t buy anything now? :) @ChezCoder
Just use the reset button

Profile icon
ChezCoder

@NoelBryan cuz Infinity is not a number.
I can just use my other hax to set it to 0

Profile icon
NoelB33

Awww, cmon @ChezCoder
It’s great that infinity is not a number though

Profile icon
ChezCoder

@NoelBryan i can easily change that >:)

Profile icon
NoelB33

why >:( noooo @ChezCoder

Profile icon
ChezCoder

@NoelBryan done >:) auto infinity correction, a bunch of bug fixes, and I styled it in a way to make it look fancy

Profile icon
NoelB33
Profile icon
TheForArkLD

Next : Save user’s data to cookie

Profile icon
NoelB33

Cookies inside of cookie clicker! @TheForArkLD

Profile icon
BobTheTomatoPie

This is really cool, you should add some more art to make it really pop out, but it's really cool! Could be the next best Idle game!

Profile icon
NoelB33
Profile icon
AmazingMech2418
Profile icon
NoelB33

The amount your +6 cookies per click costs is astounding. @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan LOL! This is what happens when you bot a JS cookie clicker...

Profile icon
NoelB33

You botted it LOL @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan Yep! I also actually changed the click variable to Number.MAX_VALUE...

Profile icon
NoelB33

Why is everyone exploiting the console @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan You should have seen mine for the "How Well Do You Know Repl.it" quiz... I finished it in 7 seconds...

Profile icon
NoelB33

What if it was legit @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan Well, I answered all of the questions in that time, just with a bot...

Profile icon
NoelB33

How did you do the bot? Seems like your good at bots @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan Well, it was a JS bot. I just copied and pasted code I created for the bot (using setInterval) into the console.

Profile icon
NoelB33

Oh, ok, cool! @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan Thank you! I also have created a bot for my own game before...

Profile icon
NoelB33

You could make games just to create bots lol @AmazingMech2418

Profile icon
AmazingMech2418

@NoelBryan LOL! Yeah.

Profile icon
NoelB33

@AmazingMech2418 then you get practice in making bots and making ther stuff :o

Profile icon
NoelB33

I’m getting a warning: 76 percent scanned too many errors, anybody know how to fix this? (It still works it’s just a warning.)

Profile icon
DeBeast591

Add a counter for how many cookies per click you have. Other than that, it's awesome!

Profile icon
NoelB33

Ok, I will! @DeBeast591

Profile icon
NoelB33
Profile icon
DeBeast591

@NoelBryan Awesome!

Profile icon
Bookie0

Cool I love cookies 🍪 🍪 🍪🍪🍪🍪🍪🍪😃😃🍪🍪🍪🍪🍪

Profile icon
NoelB33

Cookies are tasty @Bookie0

Profile icon
Bookie0

@NoelBryan indeed

Profile icon
3465728974563

Hey @NoelBryan ! I was wondering if you would be interested in doing a collab project. It doesn't have to be based on the same thing, but I think it would be interesting to work together on a project. I do know HTML, Javascript and CSS pretty well, and I think it'd be fun to work on something together. Are you interested? Also great job on making something like this so far. I know that it can be hard to make something like this, and it most likely involved a lot of testing and going back over and over. So great job making a game of this scale.

Profile icon
NoelB33

Thanks! I’m interested! Contact me on discord GDmaster33#3747 @3465728974563

Profile icon
3465728974563

@NoelBryan will do!

Profile icon
NoelB33
Profile icon
[deleted]

Cool! love it!

Profile icon
NoelB33

Thanks! @Zuhdi28

Profile icon
[deleted]

NoelBryan no problem...

Profile icon
[deleted]
Profile icon
NoelB33

What do you need help with? @Zuhdi28
And I can’t right now, maybe in like a coupe, hours, sorry.

Profile icon
[deleted]

@NoelBryan ok np
i'll tell you what i need when you be here!
BYE

Profile icon
[deleted]

I "hacked" it really quickly. Just did clicks=100000000.

Profile icon
NoelB33
Profile icon
[deleted]
Profile icon
[deleted]

amazing!

Profile icon
NoelB33
Profile icon
CodingGoose

I love this!

Profile icon
NoelB33

@DannyIsCoding Thank you!

Profile icon
BobNeo

Cool but the background is a weird color, can you change the color?

Profile icon
NoelB33