Preventing cheat in a clicker game in web

238 Views Asked by At

If you seen my previous question, you will know that I'm starting on a project. It requires you to grind clicks then spend it. But I want to prevent user from cheating using auto-clicker extensions. So, is there anyways that I can prevent user from cheating?

Here's my code:

@import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');

body{
    background: linear-gradient(to right, #11998e, #38ef7d)
}

#title{
    text-align: center;
    font-family: 'Montserrat';
    font-size: 48px;
    font-weight: bold;
    user-select: none;
    margin-top: 2%;
}

#button{
    margin: auto;
    width: 50%;
    height: auto;
    padding: 15px;
    text-align: center;
    border: 3px solid white;
    border-radius: 50px;
    font-family: 'Montserrat';
    font-size: 32px;
    font-weight: bold;
    user-select: none;
    transition-duration: 0.1s;
}

#button:hover{
    cursor: pointer;
    transition-duration: 0.1s;
    background-color: white;
}

#button:active{
    transition-duration: 0.1s;
    transform: scale(0.9);
}
<!DOCTYPE html>
<html>
    <head>
        <title>This is just test</title>
        <script src="clicker.js"></script>
        <link rel="stylesheet" href="clicker.css">
    </head>
    <body>
        <p id="title">Clicker Test</p>
        <div id="button">
            <span id="text">Score:</span>
            <span id="score">0</span>
        </div>
        <script>
            let counter = 0;
  
            document.getElementById('button').onclick = () => {
                document.getElementById('button').style.width = '45%';
                document.getElementById('button').style.width = '50%'
                counter = counter + 1;
                document.getElementById('score').innerText = counter;
            };
        </script>
    </body>
</html>

0

There are 0 best solutions below