npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xan105/hoyolab-rewards

v1.0.1

Published

Library to automate Hoyolab daily login rewards

Downloads

11

Readme

About

Library to automate Hoyolab daily login rewards for:

  • Honkai: Star Rail
  • Genshin Impact
  • Honkai Impact 3rd
  • Tears of Themis

Example

import { checkin } from "@xan105/hoyolab-rewards";

console.log("Checking-in...");
const reward = await checkin("starrail", token, { lang: "en-us", loot: true });
if (reward) console.log(`Got: ${reward.cnt} x ${reward.name}`); 
//"Got: 20 x Stellar Jade"
console.log("✔️ done");

Install

npm install @xan105/hoyolab-rewards

API

⚠️ This module is only available as an ECMAScript module (ESM).

Named export

checkin(name: string, token: object, option?: object): Promise<void | object>

Check-in and get the daily reward for the specified game name using the given token for authentification.

Games

  • starrail : Honkai: Star Rail
  • genshin : Genshin Impact
  • honkai : Honkai Impact 3rd
  • themis : Tears of Themis

Token

Your session token represented as a plain object:

{
  ltoken: string,
  ltuid: string,
  mhyuuid: string,
  devicefp: string,
  devicefp_seed_id: string,
  devicefp_seed_time: string
}

To retrieve your session token. Go to the daily login page of the game you wish to automate:

Open the console in the dev tool of your browser (F12) and type document.cookie. This will output something like:

ltoken=...; ltuid=...; G_ENABLED_IDPS=google; mi18nLang=en-us; DEVICEFP=...; DEVICEFP_SEED_ID=...; DEVICEFP_SEED_TIME=...; _MHYUUID=...

Use these key/pair values to create a plain object representing your session token.

Options

{
  lang?: string,
  loot?: boolean
}
  • lang: string | "en-us"

    Language code. Try to keep it in sync with mi18nlang.

  • loot: boolean | false

    Whether to return the reward output or not (eg: 20x Stellar Jade). This will require an additional network request.

Return value

When the loot option is set to true returns the reward output:

{
  icon: string, //icon url
  name: string, //reward name
  cnt: string //reward count
}

💡 Output is affected by the language code used.

❌ This promise will reject on error.

CLI

There is a crude CLI tool provided as an implementation example in the package.json bin field.

hoyolab-checkin --game=starrail

Token information can be either provided by environment variable or by arguments:

hoyolab-checkin --game=starrail --ltoken=... --ltuid=... [...]

environment variables are prefixed with HOYOLAB_ and are all uppercase.

set HOYOLAB_LTOKEN=...
set HOYOLAB_LTUID=...
...
hoyolab-checkin --game=starrail

GitHub action

Check out .github/workflows/hoyolab-daily-reward.yml found in this repo for an example of a github action running the above CLI on a daily schedule.