anchvy's website logo

Memo: What I can see from POPCAT.CLICK as a Frontend engineer

Introduction

The POPCAT.CLICK is a popular competitive clicker web at this moment. A user can click on the screen or using keyboard key to increase the click number of mine and country stat. There is a leaderboard which is descending ordered by country.

Please see the official document here https://freddyheppell.com/work/popcat

What I can see

The below detail is written based on the current version on Aug 17th, 2021. Since the sourcemap is not removed on production build. So, the source code can be checked directly on Chrome browser.

the actual src will not be added here since I just need to learn how they handle this game

  • We can see that the website has been implemented by vuejs
  • The current location is checked by API on created lifecycle hook and saved to Browser Cookie after first successfully stat updated. If I access to the web within 12hr (0.5 day), the exisiting value will be used.
  • The event listeners have been added to the window.document, That mean we can click anywhere on the site to increase the number.
  • The sound is random on click and that makes it not boring!
  • We cannot hold down a keyboard key to increase the number since the event.repeat is being checked
  • The reCAPTCHA token is being used as an auth and maybe also checked the score of request whether it is spam or not (?). By doing this, to call an endpoint to update number directly with POSTMAN might not that easy
  • The stat is not updated on click but it will be counted locally and updated after 30 seconds from first click. After that the count will be sent to API every 30 seconds if I have click more within each cycle.
  • If the local count is more than 800, only 800 will be sent to stat API (It might hurt an autoclicker xD)
  • If I am trying to click more than 800 clicks 11+ times within 30 seconds, I will be marked as a BOT and the bot is not allowed to update any click count for 12hr. In addition, the cat will be ANGRY
  • Number of my click will be stored in Browser Cookie for a year~
  • The leaderboard will be refetched in 5 seconds after the current request is finished

Remark

  • Remove the source map on production build might be better. Even we cannot avoid other ppl to check the source code but it will be a bit harder than not removing it.
  • Since all data are stored in Browser Cookie... I think you know what I mean ;)
  • When using vuejs, we can update some local data directly on dev console
  • Moreover, I am also interested how they handle massive request from ppl around the world on the backend side. Can't wait to read their official document!
  • IMO, maybe using debounce to send stat after X seconds from last click might help reduce a request from client (in case that user keeps clicking the cat)
  • I LOVE THIS CAT.

Latest articles!

Memo: Web performance runtime Q&A

CSS: PX to REM Calculator

VSCode Tip: Find all usage of specific variable across files in workspace