DEV Community

loading...
Cover image for How I Hacked Cookie Clicker Game with Inspect Element

How I Hacked Cookie Clicker Game with Inspect Element

Muhammad Furqan Ul Haq
I’m a freelance Web Developer, SEO Expert, and Author. I developed tons of websites and wrote 1500+ programming articles.
・3 min read

How I Hacked Cookie Clicker Game with Inspect Element

Cookie Clicker is a very popular browser-based game. It revolves around producing cookies for the world. This game gets more interesting over time which keeps the player engaged.

Basically, there are a few ways to get cookies. These cookies can then be used to create new buildings or purchase upgrades. At first, I’m going to mention a few genuine ways to earn cookies.

  • By clicking the big “Cookie” shown on the user interface.
  • By creating new buildings. There are different types of buildings and each type can only produce a specified number of cookies per second. Initially, all buildings are locked, but they will get unlocked over time as the game progresses.
  • By enhancing the efficiency of your cookie store through upgrades.

Now, here comes the actual hacking stuff you’re waiting for.

Getting Started

As I mentioned earlier, this is a browser-based game. Meaning that it is developed using HTML5, CSS3, and JavaScript. All of these are client-side languages that can be modified through programs like Chrome DevTools.

Let’s open this game in Google Chrome.

Now to open Chrome DevTools, right-click anywhere on the game and select “Inspect” from the context menu. For now, we will only be focusing on its functionality that is written in JavaScript. So, open the “Console” tab.

Another way is to press Ctrl+Shift+J on Windows or ⌘+⌥Option+J on Mac.

You’ve to execute the below-mentioned codes here.

It’s time to hack different features of this Cookie Clicker game.

Hack Cookies

As everything in this game depends on cookies, so I hacked them!

Basically, after analyzing its source code, I found that the functionality of this game is written inside a file called “main.js”.

This file initializes an object Game through which we can easily access different features of Cookie Clicker. For example, we can modify the number of cookies we have using the Game.cookies property.

Let’s do that now!

Simply copy the below code and paste it inside the “Console” tab of Chrome DevTools. Press “Enter” to execute it.

Game.cookies = 57000
Enter fullscreen mode Exit fullscreen mode

Once executed, you will get 57000 cookies absolutely FREE. You can add any number here.

For example, the below code will give you “Infinity Cookies”.

Game.cookies = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Enter fullscreen mode Exit fullscreen mode

Keep Getting Cookies

This game also has the functionality of earning cookies per second. Game.cookiesPs property will give us a specified number of cookies for one second.

So, why not wrap it inside a setInterval of one second to continuously get more and more cookies?

Here’s the code snippet to do so.

setInterval(function(){
    Game.cookiesPs = 50
}, 1000);
Enter fullscreen mode Exit fullscreen mode

This code will add 50 cookies to your account every second.

Unlock All Upgrades and Purchase Them

Finally, the developers of Cookie Clicker have also provided a cheat to get all upgrades for free.

Basically, the below method will give you all upgrades as well as unlocks all types of buildings. Additionally, you will get 1.000 nonillion cookies.

Game.RuinTheFun();
Enter fullscreen mode Exit fullscreen mode

Now you might be wondering can we hack other browser-based games too?

And the answer is "Yes, definitely!"

You can hack any game no matter whether it is browser-based, Android, or even PC.

I would like to mention that I learned game hacking from guidedhacking.com. It is the best community forum that helps us understand all the concepts of game hacking in a step-by-step manner.

Spend some time there!

You'll find game hacking tutorials and guides right from their main menu. If you find something difficult then you can always ask questions from fellow hackers.

At last, I would say that game hacking is not very difficult. It just depends on how much time you can dedicate to learn it.

Discussion (26)

Collapse
proprogrammer2432 profile image
ProProgrammer2432 • Edited

DUDE THE LAST COMMAND GAVE ME BUG IN THE GAME
dev-to-uploads.s3.amazonaws.com/up...

Collapse
trulyfurqan profile image
Muhammad Furqan Ul Haq Author

By "bug" did you mean error or the insects that are eating cookies?

Collapse
proprogrammer2432 profile image
ProProgrammer2432

insects that are eating cookies

Collapse
joshuaw94244563 profile image
Baby._.Steve

ME TOO IT SUCKS THAT LAST ONE

Collapse
proprogrammer2432 profile image
ProProgrammer2432

I KNOW RIGHT!!!!!

Collapse
rileywheeler profile image
rileywheeler

It's a really incredible trick, I can make a little joke to my friends :)

Collapse
kirilllive profile image
Kirill Live

It was interesting, I didn’t know that Cookie Clicker works like that.

Collapse
trulyfurqan profile image
Muhammad Furqan Ul Haq Author

Yeah. It is a very engaging game. I really like the way it progresses.

A few years ago, I hacked Google Chrome's Dinosaur Game and published a blog post on it. That article got really popular. So, today I decided to try hacking this Cookie Clicker. 😉

Here's a link to the "Dinosaur Game Hacked" article if you're interested.

link: JavaScript Code Plays Google Dinosaur/T-Rex Game Automatically

Collapse
eileenjmartinez profile image
eileenjmartinez

I can play Cookie clicker without getting bored, but after a while I'm really tired of clicking, so I play basketballlegendsunblocked for him.

Collapse
trantien18 profile image
Super Mario Bros Game • Edited

I usually play cookie clicker on: cookie clicker
And can play more and more io games in one place. no need to find more.

Collapse
johnsmith9902 profile image
johnsmith9902

Login to thanks you, i can spend hours to play game on this site.

Collapse
proprogrammer2432 profile image
ProProgrammer2432
Collapse
devfranpr profile image
DevFranPR

Man I don't even finished a complete run but now I feel stupid for not trying first.

Collapse
trulyfurqan profile image
Muhammad Furqan Ul Haq Author

😄

Collapse
thedevking profile image
TheDevKing1

Now my cookie clicker is glitched. It said I have an "Infinite" amount of cookies.

Collapse
techysudheer profile image
Sudheer Techy

Watch cartoon for free on Watch Cartoon Online official website.

Collapse
techysudheer profile image
Sudheer Techy

Thank you for sharing this. I have done the same using WebLogic Training

Collapse
coolastro_com profile image
Cool Astro
Collapse
the_lusquitas profile image
Lucas Silva

But, is It a Win, If you sacrifice the Fun?

Collapse
trulyfurqan profile image
Muhammad Furqan Ul Haq Author

You are right. But, sometimes analyzing others code and finding vulnerabilities in it is also fun and interesting.

I think it's a way to improve our programming skills.

Collapse
dbillio profile image
DBillio

Hahah, amazing! I wish you good luck in your future hacks

Collapse
trulyfurqan profile image
Muhammad Furqan Ul Haq Author

Thanks bro 😍

Some comments have been hidden by the post's author - find out more