This project runs a Puppeteer-based automation inside Docker and keeps the container alive with cron. The job runs twice a day at 02:30 and 14:30 using the container’s own scheduler.
- Opens the TryHackMe
tickets3room. - Runs the reset flow.
- Submits the room check.
- Sends optional Gotify or Telegram notifications.
- Retries up to 5 times with a 30 second delay between attempts.
- Prevents overlapping runs with a lock file.
index.js— main automation script.login.js— manual login helper that saves cookies.config.js— static settings for room URL, selectors, retry timing, and notifications.notifications.js— Gotify / Telegram notification helpers.state.js— stores run state so the second daily run can exit early if the streak was already secured.run.sh— lock wrapper to prevent overlapping runs.crontab— cron schedule for the container.Dockerfile— container image.docker-compose.yml— Compose setup for running the container.cookies.json— saved TryHackMe session cookies.
npm installRun the login helper:
node login.jsA browser window will open. Log in manually to TryHackMe, then confirm in the terminal so the cookies are saved to cookies.json.
node index.jsIf the session is valid, the script should run the reset/check flow and print the API response.
Build and start the container:
docker compose up -d --buildCheck status:
docker compose psView logs:
docker compose logs -fThe Compose file mounts:
./cookies.jsoninto/app/cookies.json../logsinto/var/log.
The container runs cron in the foreground. Cron executes /app/run.sh at:
- 02:30 daily
- 14:30 daily
run.sh uses flock so if one run is already active, the next scheduled run exits immediately instead of overlapping.
Each scheduled run retries the automation up to 5 times with a 30 second delay between attempts. This is intended to handle temporary failures without retrying forever.
Overlap is prevented in two ways:
flock -n /tmp/tryhackme.lockblocks concurrent runs.- The daily state file can be used so the second run exits early if the streak was already increased earlier that day.
Optional notification support is available for:
- Gotify.
- Telegram.
Notification text is based on the API response:
- If
isStreakIncreasedistrue, the message says the streak is alive and includes the new streak number. - If
isStreakIncreasedisfalse, the message warns that the streak is in danger.
The title includes the current date, for example:
TryHackMe (2026-06-01)
If the session expires:
- Stop the container.
- Run
node login.js. - Save the new
cookies.json. - Start the container again:
docker compose up -dCron output is written to the mounted ./logs directory on the host.
Example:
tail -f ./logs/tryhackme.log- Keep
cookies.jsonprivate. - Do not commit cookies to version control.
- If the room UI changes, update the selectors in
config.js. - If the challenge page appears instead of the room, the current session or browser verification may need attention.