Skip to content

Latest commit

 

History

History
126 lines (91 loc) · 6.63 KB

File metadata and controls

126 lines (91 loc) · 6.63 KB

HoyoLab Check-In Helper

Contents

Pre-requisites

  • Google Account

Setting up

1. Setup in Google Apps Script

  1. Check-In URLs:

  2. Getting the Cookie:

    • Follow the HoyoLab Cookie Extraction Guide to obtain the cookie required for both daily check-ins and code redemption.
    • Use an incognito/private browsing window as recommended in the guide to ensure you copy the correct account's cookie.

2. Setup in Google Apps Script

  1. Create a New Project:

  2. Paste the Code:

    • Replace any existing code in the script editor with the provided Apps Script code. It should look like this:

      image

  3. Configuration:

    • Paste your cookie: In the config object, add the following (replace placeholders with your actual data):

      const config = {
        genshin: {
          data: [
            // "account_cookie_1",
            // "account_cookie_2",
            // ... more account cookies
          ]
        },
        honkai: {
          data: [
            // "account_cookie_1",
            // "account_cookie_2",
            // ... more account cookies
          ]
        },
        starrail: {
          data: [
            // "account_cookie_1",
            // "account_cookie_2",
            // ... more account cookies
          ]
        }
      };
    • Discord notifications (optional): Set DISCORD_WEBHOOK to your webhook URL to get a Discord message for every check-in.

      const DISCORD_WEBHOOK = "https://discord.com/api/webhooks/...";
    • Automatic code redemption (optional): Set enableCodeRedemption to true to redeem new codes on each scheduled run, including when the account has already checked in that day. Not supported for Honkai Impact 3rd.

      const config = {
        enableCodeRedemption: true,  // redeem new codes automatically
        notifyOnRedeemFailure: false, // also report codes that failed to redeem
        // ...
      };

      When DISCORD_WEBHOOK is set, one summary message is sent per account listing the codes that were redeemed and the rewards they granted. Nothing is sent when there are no new codes. Turn on notifyOnRedeemFailure if you also want to hear about codes that failed - this includes a link to redeem them manually. Codes that fail for a temporary reason (expired cookie, redemption cooldown, network errors) are retried on the next run; expired, invalid, and already-used codes are not.

      Authentication failures send a separate Discord alert even when notifyOnRedeemFailure is false. Check-in and redemption failures are deduplicated per game and HoYoLAB account across runs. A failed delivery is retried; another alert is allowed after the cookie changes or all reported authentication failures recover. Alerts show the HoYoLAB ID, plus the game UID, nickname, and region once the account has been looked up successfully at least once. After a redemption login error, remaining codes for that account wait until the next run. Other accounts continue normally.

      Check-in and redemption use different tokens, so successful check-in does not prove that redemption credentials are valid. Replace the affected account's cookie when alerted. This Apps Script does not refresh cookies using stoken.

      Redeemed codes are now tracked per game account. When updating from a version with shared code history, current codes may be attempted once again for each account because the old history cannot identify which account redeemed them.

    • Save the Project: Click on the floppy disk icon to save your project.

      image

3. Run the Script

  1. Before Running It:

    • Make sure to select checkInAllGames or the script will not run.

      image

  2. Trigger the Function (Recommended):

    • In the Apps Script editor, click on the "Triggers" icon (clock symbol) in the left sidebar.
    • Click "+ Add Trigger" and configure:
      • Function to run: checkInAllGames
      • Event source: Time-driven
      • Type of time-based trigger: Day timer
      • Select time: Set your desired time for daily check-ins.
    • Save the trigger. This will automatically run your script every day at the specified time.
  3. Final Step:

    • Run the script once manually by clicking the play button in the Apps Script editor to authorize the script.

      image

Optional six-hour cookie keep-alive

Run setupCookieKeepAlive once from the Apps Script editor and authorize it if prompted. This creates a separate trigger that runs keepAliveCookies every six hours. Running setup again replaces your existing keep-alive trigger. Your daily check-in trigger stays as configured.

Each run reads the check-in status for each configured game/account without checking in or redeeming codes. Successful requests send no Discord messages; authentication failures use the existing deduplicated alerts. A successful keep-alive does not clear a code-redemption authentication failure.

This is experimental: periodic requests have not been verified to extend cookie lifetime or prevent CAPTCHA. It does not refresh tokens using stoken, save replacement cookies, or restore expired sessions. Expired cookies still need replacing.

To stop it, run removeCookieKeepAlive from the editor. Trigger setup and removal apply to triggers created by your Google account.

Important Notes

  • Authorization: The first time you run the script, it will ask for authorization to access your Google account.
  • Logs: View the execution logs by clicking on the "Executions" icon (play button symbol) in the Apps Script sidebar.