/hoyolab-auto-sign

A lightweight, secure, and free script that automatically collect Hoyolab daily check in rewards. Supports Genshin Impact, Honkai Impact 3rd, and Honkai: Star Rail.

Primary LanguageJavaScriptMIT LicenseMIT


hoyolab-auto-sign


繁體中文 English Русский

A lightweight, secure, and free script that automatically collect HoYoLAB daily check in rewards.
Supports Genshin Impact, Honkai Impact 3rd, and Honkai: Star Rail. Support multiple accounts.

Features

  • Lightweight - The script only requires minimal configuration and is only 90 lines of code.
  • Secure - The script can be self-deployed to Google Apps Script, no worries about data leaks.
  • Free - Google Apps Script is currently a free service.
  • Simple - The script can run without a browser and will automatically notify you through Discord or Telegram.

Setup

  1. Go to Google Apps Script and create a new project with your custom name.
  2. Select the editor and paste the code( Discord version / Telegram version ). Refer to the instructions below to configure the config file and save it.
  3. Select "main" and click the "Run" button at the top.
    Grant the necessary permissions and confirm that the configuration is correct (Execution started > completed).
  4. Click the trigger button on the left side and add a new trigger.
    Select the function to run: main
    Select the event source: Time-driven
    Select the type of time based trigger: Day timer
    Select the time of day: recommended to choose any off-peak time between 0900 to 1500.

Configuration

const profiles = [
  { token: "ltoken_v2=v2_CANARIAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3406; ltuid_v2=26XXXXX20;", 
    genshin: true, 
    honkai_star_rail: true, 
    honkai_3: false, 
    accountName: "YOUR NICKNAME" }
];

HoYoLAB has changed the rules for tokens on July 2023, switching from the previous "ltoken" and "ltuid" to "ltoken_v2" and "ltuid_v2".

Important

HoYoLAB has changed the cookie to HttpOnly cookie. It is no longer possible to read the cookies by using the getToken.js code.
Please use the method of manually copying the cookie to obtain the ltoken_v2 and ltuid_v2.
For more detail: https://github.com/Joshua-Noakes1/mei-cards#2-getting-your-hoyolab-cookies

HoYoLAB settings
  1. token - Please enter the token for HoYoLAB check-in page.

    After entering the HoYoLAB check-in page, press F12 to enter the console.
    Paste the following code and run it to get the token. Copy the token and fill it in "quotes".

    HoYoLAB has changed the cookie to HttpOnly cookie. It is no longer possible to read the cookies by using the getToken.js code.
    Please use the method of manually copying the cookie to obtain the ltoken_v2 and ltuid_v2.

  2. genshin

    Whether to enable auto check in for Genshin Impact.
    If you want, set it to true. If not, please set it to false.
    If you do not play Genshin Impact, or your account is not bound to a uid, please set it to false.

  3. honkai_star_rail

    Whether to enable auto check in for Honkai: Star Rail.
    If you want, set it to true. If not, please set it to false.
    If you do not play Honkai: Star Rail, or your account is not bound to a uid, please set it to false.

  4. honkai_3

    Whether to enable auto check in for Honkai Impact 3rd.
    If you want, set it to true. If not, please set it to false.
    If you do not play Honkai Impact 3rd, or your account is not bound to a uid, please set it to false.

  5. accountName - Please enter your customized nickname.

    Please enter your customized HoYoLAB or in-game nickname here.

discord notify settings (only for Discord version)
const discord_notify = true
const myDiscordID = "20000080000000040"
const discordWebhook = "https://discord.com/api/webhooks/1050000000000000060/6aXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnB"
  1. discord_notify

    Whether to enable Discord notify.
    If you want to enable auto check-in notify, set it to true. If not, please set it to false.

  2. myDiscordID - Please enter your Discord user ID.

    Whether you want to be ping when there is an unsuccessful check-in.
    Copy your Discord user ID which like 23456789012345678 and fill it in "quotes".
    You can refer to this article to find your Discord user ID.
    If you don't want to be pinged, leave the "quotes" empty.

  3. discordWebhook - Please enter the Discord webhook for the server channel to send notify.

    You can refer to this article to create a Discord webhook.
    Once you have finished creating the Discord webhook, you will receive your Discord webhook URL, which like https://discord.com/api/webhooks/1234567890987654321/PekopekoPekopekoPekopeko06f810494a4dbf07b726924a5f60659f09edcaa1.
    Copy the webhook URL and paste it in "quotes".

telegram notify settings (only for Telegram version)
const telegram_notify = true
const myTelegramID = "1XXXXXXX0"
const telegramBotToken = "6XXXXXXXXX:AAAAAAAAAAXXXXXXXXXX8888888888Peko"
  1. telegram_notify

    Whether to enable Telegram notify.
    If you want to enable auto check in notify, set it to true. If not, please set it to false.

  2. myTelegramID - Please enter your Telegram ID.

    Use the /getid command to find your Telegram user ID by messaging @IDBot.
    Copy your Telegram ID which like 123456780 and fill it in "quotes".

  3. telegramBotToken - Please enter your Telegram Bot Token.

    Use the /newbot command to create a new bot on Telegram by messaging @BotFather.
    Once you have finished creating the bot, you will receive your Telegram Bot Token, which like 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw.
    Copy your Telegram Bot Token and fill it in "quotes".
    For more detailed instructions, you can refer to this article.

Demo

If the auto check in process is success, it will send "OK".
If you have already check in today, it will send "Traveler/Trailblazer/Captain, you've already checked in today"

Single HoYoLAB account auto check-in with Discord notification and ping. Enable Genshin Impact and Honkai: Star Rail auto check in, enable Discord notify, ping in Discord.
const profiles = [
  { token: "account_mid_v2=123xyzabcd_hi; account_id_v2=26XXXXX20; ltoken_v2=v2_CANARIAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3406; ltmid_v2=123xyzabcd_hi; ltuid_v2=26XXXXX20;", 
    genshin: true, 
    honkai_star_rail: true, 
    honkai_3: false, 
    accountName: "HuTao" }
];

const discord_notify = true
const myDiscordID = "240000800000300040"
const discordWebhook = "https://discord.com/api/webhooks/10xxxxxxxxxxxxxxx60/6aXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXnB"

image

Two HoYoLAB accounts auto check-in with Telegram notification. Enable Genshin Impact auto check-in on accountA, Honkai Impact 3rd auto check-in on accountB, enable Telegram notify.
const profiles = [
  { token: "account_mid_v2=123xyzabcd_hi; account_id_v2=26XXXXX20; ltoken_v2=v2_CANARIAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3406; ltmid_v2=123xyzabcd_hi; ltuid_v2=26XXXXX20;", 
    genshin: true, 
    honkai_star_rail: false, 
    honkai_3: false, 
    accountName: "accountA" },
  { token: "account_mid_v2=456qwertyu_hi; account_id_v2=28XXXXX42; ltoken_v2=v2_GENSHINXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX5566; ltmid_v2=456qwertyu_hi; ltuid_v2=28XXXXX42;", 
    genshin: false, 
    honkai_star_rail: false, 
    honkai_3: true, 
    accountName: "accountB" }
];

const telegram_notify = true
const myTelegramID = "1XXXXXXX0"
const telegramBotToken = "6XXXXXXXXX:AAAAAAAAAAXXXXXXXXXX8888888888Peko"

image

Changelog

2022-12-30 Project launched.
2023-04-27 Add support for Honkai Impact 3rd, and Honkai: Star Rail.
2023-04-27 Add switch for Discord notify.
2023-05-12 Update get token process#2.
2023-05-12 Add Telegram notify support#3.
2023-05-13 Support multiple HoYoLAB accounts#4