hoyolab-daily-checkin
Collect the Hoyolab daily check-in rewards for Genshin Impact, Honkai Impact 3rd, Honkai Star Rail and Tears of Themis automatically!.
Usage
Simply fork this repository or create a new one and edit/create the workflow file to run the daily check-in action. No worries if you don't know much about git or github actions - you can easily edit and save the file using the online editor - almost everything else happens ✨ automagically ✨!
Step-by-Step Walkthrough
Create a fork.
Fork this repository into your GitHub account and navigate there.
Links in the following description that are relative to your fork's URL for convenience are marked with (R).
Get the login token
For the check-in in order to work, we need the user ID and the access token from the Hoyolab cookie - this token is valid for all games that are registered with your Hoyolab account.
Open your webbrowser, navigate to Hoyolab Circles and log in with the hoyolab account you want to use.
Now it gets a little bit scary: open the browser's developer console (usually by pressing F12
), go to the "console" tab and paste the following code snippet:
let cookies = document.cookie.split(';').map(v => v.trim().split('='));
console.log(cookies.map(([k, v]) => ['ltuid', 'ltoken'].includes(k) ? `${k}=${v};` : null).filter(v => v).join(' '));
When you hit Enter
it will return a line similar to the following - copy that line:
ltuid=000000000; ltoken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
Add repo secrets
Since the credentials are sensitive information, we don't want them committed to the public main branch, so we will to add them as repository secrets instead. GitHub will automatically remove anything stored as repo secret from all logs and output so that sensitive data won't get leaked.
Go to the repository secrets settings (R), click "New repository secret", enter a descriptive name, paste the token from the previous step into the text box below and save it.
It's important that you do not log out from the Hoyolab account - logging out will invalidate the token, and you will need to repeat the previous steps and update the secret(s). The token may expire, in which case you also need to repeat the procedure.
Edit the workflow file
Open the workflow file (R) in your local editor/IDE or in the web-editor (R) and start editing! The most basic workflow would look like this:
on:
push:
branches:
- main
schedule:
# POSIX cron syntax (daily 17:00 UTC), see https://crontab.guru/#0_17_*_*_*
- cron: "0 17 * * *"
jobs:
hoyolab-checkin:
name: "Hoyolab daily check-in"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Hoyolab check-in (Account 1)"
uses: codemasher/hoyolab-daily-checkin-action@main
with:
cookie: ${{ secrets.ACCOUNT1 }}
genshin: true
honkai3rd: false
starrail: false
tearsofthemis: false
That's easy enough to understand, no? You will need to set true
for each game you have registered with your Hoyoverse account, otherwise false
or omit the parameter.
If you want to check-in for more accounts, you need to duplicate the Hoyolab check-in (Account X)
step and add secrets for each account.
(Just be careful with the indentation, YAML is very picky about that...)
When you're done editing, save/commit the file and head over to the actions tab (R) where a new workflow run should pop up.
Update: it seems that editing via the web interface does not always trigger a git push
event properly that would start a job run, so you will need to wait for the scheduled job in that case.
Notification settings
Language
You can change the language
for the returned messages in the GitHub actions log and other notifications:
- name: "Hoyolab check-in (Account 1)"
uses: codemasher/hoyolab-daily-checkin-action@main
with:
cookie: ${{ secrets.ACCOUNT1 }}
genshin: true
# ...
language: "zh-tw"
# ...
The language parameter defaults to en-us
and can be one of:
zh-cn
(Chinese, traditional)zh-tw
(Chinese, simplified)de-de
(German)en-us
(English)es-es
(Spanish)fr-fr
(French)id-id
(Indonesian)it-it
(Italian)ja-jp
(Japanese)ko-kr
(Korean)pt-pt
(Portugese)ru-ru
(Russian)th-th
(Thai)tr-tr
(Turkish)vi-vn
(Vietnamese)
Account description
The account-description
setting allows you to add an account description that will be used as identifier in external notifications (e.g. Discord) - the value will be truncated to 100 (8bit) characters.
- name: "Hoyolab check-in (Account 1)"
uses: codemasher/hoyolab-daily-checkin-action@main
with:
cookie: ${{ secrets.ACCOUNT1 }}
genshin: true
# ...
account-description: "Main Account"
# ...
Only notify on failed jobs
If you want external notifications only when a job run has failed, set only-notify-failed
to true
(default), set it to false
for all the notifications.
- name: "Hoyolab check-in (Account 1)"
uses: codemasher/hoyolab-daily-checkin-action@main
with:
cookie: ${{ secrets.ACCOUNT1 }}
genshin: true
# ...
only-notify-failed: true
# ...
Discord notifications
You can enable Discord notifications via webhook to a channel on your server. In order to do so , set discord-notify
to true
and add the
discord-webhook
(how to get a Discord webhook URL) and optionally the
discord-user-id
to ping (how to get the user ID) as repository secrets.
- name: "Hoyolab check-in (Account 1)"
uses: codemasher/hoyolab-daily-checkin-action@main
with:
cookie: ${{ secrets.ACCOUNT1 }}
genshin: true
# ...
language: "zh-tw"
account-description: "Main Account"
only-notify-failed: false
# ...
discord-notify: true
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
discord-user-id: ${{ secrets.DISCORD_USER_ID }}
Advanced
To run several accounts on a matrix, which will start a separate job for each account and will continue even if one job fails, you could do something like this:
jobs:
hoyolab-checkin:
name: "Hoylab daily check-in"
runs-on: ubuntu-latest
strategy:
fail-fast: false # will continue to run jobs even if one has failed
matrix:
include:
- cookie: ACCOUNT1 # only the name of the cookie secret, variables don't work here
description: "Account 1"
genshin: true
honkai3rd: true
starrail: true
tearsofthemis: false
# repeat for each account
- cookie: ACCOUNT2
description: "Account 2"
genshin: true
honkai3rd: false
starrail: false
tearsofthemis: false
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Hoyolab check-in"
uses: codemasher/hoyolab-daily-checkin-action@main
with:
cookie: ${{ secrets[matrix.cookie] }}
genshin: ${{ matrix.genshin }}
honkai3rd: ${{ matrix.honkai3rd }}
starrail: ${{ matrix.starrail }}
tearsofthemis: ${{ matrix.tearsofthemis }}
language: "en-us"
account-description: ${{ matrix.description }}
only-notify-failed: false
discord-notify: true
discord-webhook: ${{ secrets.DISCORD_WEBHOOK }}
discord-user-id: ${{ secrets.DISCORD_ID }}
Disclaimer
WE'RE TOTALLY NOT RUNNING A PRODUCTION-LIKE ENVIRONMENT ON GITHUB.
WE'RE RUNNING A TEST AND POST THE RESULT TO AN EXTERNAL WEBSITE.
WE'RE JUST LOOKING IF THE SCRIPT STILL WORKS ON A DAILY SCHEDULE.
I take no responsibility for the security of your account(s) by using this script.