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

hoyocheckin

v1.2.0

Published

A simple package for HoYoLAB check-ins

Downloads

25

Readme

HoyoCheckIn

A simple, fast and functional npm package for HoYoLAB check-ins in your project.

Commits License

Key Features

  • Supports Honkai: Star Rail, Genshin Impact and Honkai Impact 3rd.
  • Supports custom user agents, and defaults to a human-browser one if not provided.
  • Small, efficient and functional.

Install

Installing is done via NPM.

npm install hoyocheckin

Usage

[!NOTE] Before continuing, please grab your HoYoLAB token. Specifically, ltoken and ltuid. If you do not have these already, there is a script to get them below. Please also check if your token is v2 or not, as well.

The most simple way to check-in is to not specify an User-Agent at all. It will automatically use a browsers User-Agent.

Please, also check if your token is v2 or not. If it is, you will need to specify that in the checkIn() function. If you do not provide a token version, it will default to v1.

const { checkIn, HoyoGame } = require('hoyocheckin');

const cookie = {
  ltoken: 'YOUR_LTOKEN_VALUE',
  ltuid: 'YOUR_LTUID_VALUE'
};

const game = HoyoGame.StarRail; // You can replace this with Genshin or HKImpact, for those respective games.

try {
    const checkInResult = await checkIn(cookie, game, false); // v2, or not.
    console.log('Check-in successful:', checkInResult);
  } catch (error) {
    console.error('Check-in failed:', error.message);
}

However, if you would still like to use a custom User-Agent, you may do so by simply inputting it in the CheckIn() function.

const userAgent = "Example User-Agent";

const checkInResult = await checkIn(cookie, game, false, userAgent);

You can also find out if the user has already checked in, and respond to them accordingly.

const checkInResult = await checkIn(cookie, game, false);
if (checkInResult.alreadyCheckedIn) {
  console.log(checkInResult.message);
}

HoYoLAB returns a custom message if check-in is already done, so, if you wish you can simply return that output to the user, as I have above.

Just as an FYI, for each game they are:

  • You've already checked in today, Trailblazer~
  • Traveler, you've already checked in today~
  • You have already signed in, Captain~

How do I get my token (v1)?

[!WARNING] This method no longer functions for v2 HoYoLAB tokens. However, some users still have v1 tokens, so try this first. A method for v2 tokens is below.

Here's a script for you to get your token from HoYoLAB. Simply go to HoYoLAB, and hit Option + ⌘ + J on macOS, or Shift + CTRL + J.

After that, you can copy this script, and punch it into the console. It should return your ltuid and your ltoken. Which then, you can use in HoyoCheckIn, or any other programs that utilise it.

var ltoken = '';
var ltuid = '';

if (document.cookie.includes('ltoken') && document.cookie.includes('ltuid')) {
  var cookieArr = document.cookie.split(';');
  for (var i = 0; i < cookieArr.length; i++) {
    var cookie = cookieArr[i].trim();
    if (cookie.startsWith('ltoken')) {
      ltoken = 'ltoken=' + cookie.split('=')[1] + ';';
    } else if (cookie.startsWith('ltuid')) {
      ltuid = 'ltuid=' + cookie.split('=')[1] + ';';
    }
  }
}

if (ltoken && ltuid) {
  var cookie = ltoken + ' ' + ltuid;
  document.write(cookie);
} else {
  alert('Please logout and log back in before trying again. The cookie is currently expired or invalid!');
}

How do I get my token (v2)?

  • Go to HoYoLAB, and navigate to your profile page.
  • Open the developer console using Option + ⌘ + J on macOS, or Shift + CTRL + J, and go to the Network tab.
  • Click on the 'Preserve Log' button, then refresh the page.
  • Click on the getGameRecordCard request where the method is GET (It should be named getGameRecordCard with your HoYoLAB UID).
  • Go to the "Cookies" tab.
  • Copy the ltoken_v2 and ltuid_v2 cookie value.

Demo Screenshot

Contributing

If you have any features or fixes you'd like to contribute, open a PR.