# Using a JS Query to work as an HTML Anticheat?

So, I have a project, its a "cookie clicker" by definition, and I wish to work out how I can protect the game from users being able to edit <button id="cooker" onclick="cookieClick(1)"></button> and setting (1) to like (123129).

I tried a few things first: JQuery: I tried using an old on() function with a dom searching function, and then to run an alert saying "Dumb Hacker! Im corrupting your save data" and then of course it would run Function clearDat() then function corrupt() which clears the localstorage data and sets it to an invalid value (usually wounds up as NaN) which prevents them from Playing.

Unfortunately the cookieclicker was editing the program so hastily, that it was "changing" the button above, and I wound up getting a million alerts (And because I was using a windows based HTML editor, I was getting WINDOW alerts, which i had to spam esc and try to delete the alert function and rerun the whole game, it was a pain)

I also tried a similar method using an old JS function, but it wound up not working.

I think you may see where im getting at, I'm really stuck in a pickle.

Heres the current code: https://hatebin.com/tgsdqzhzlc

• No client-side anticheat will defeat a determined hacker. Your time and energy is likely better-spent validating game logic on your server, where you know users can't modify your code. – DMGregory Jun 22 '19 at 14:34
• In a cookie clicker, why do you care about cheating? It's a single player game; a change one player makes won't affect anyone else. – Alex F Jun 22 '19 at 17:44
• hacker doesn't need to modify your button he can just go to console and run cookieClick(1500100900) it would be a little bit more interesting if you would hide your game under private scoped variables but with your current code there is no need for such solution as you try to do there – Xesenix Jun 24 '19 at 9:27
• you need to learn a lot more to even start trying to make hackers life misserable – Xesenix Jun 24 '19 at 9:31
• Dude.... I dont care anymore, its just a dumb fricking cookie clicker LOL... get over it. – Mister SirCode Jun 24 '19 at 9:33