canaria3406/hoyolab-auto-sign

Changed the password of Hoyolab account and the auto-sign stopped

vomenh1804 opened this issue · 5 comments

So I changed my account password, then the old auto-sign keep inform me to log in
image
I tried to get new token but it say error
image
image

Please try the code below.
If it works, please tell me, thanks!

function getCookie(name) {
  const value = `; ${document.cookie}`;
  const parts = value.split(`; ${name}=`);
  if (parts.length === 2) return parts.pop().split(';').shift();
}
let token = 'Error';
if (document.cookie.includes('ltoken=')) {
  token = `ltoken=${getCookie('ltoken')}; ltuid=${getCookie('ltuid')};`;
} else if (document.cookie.includes('ltoken_v2=')) {
  token = `account_mid_v2=${getCookie('account_mid_v2')}; account_id_v2=${getCookie('account_id_v2')}; ltoken_v2=${getCookie('ltoken_v2')}; ltmid_v2=${getCookie('ltmid_v2')}; ltuid_v2=${getCookie('ltuid_v2')};`;
} else { 
  token = document.cookie;
}
let ask = confirm(token + '\n\nPress enter, then paste the token into your Google Apps Script Project');
if (ask) {
  copy(token);
  msg = token;
} else {
  msg = 'Cancel';
}

Please try the code below. If it works, please tell me, thanks!

function getCookie(name) {
  const value = `; ${document.cookie}`;
  const parts = value.split(`; ${name}=`);
  if (parts.length === 2) return parts.pop().split(';').shift();
}
let token = 'Error';
if (document.cookie.includes('ltoken=')) {
  token = `ltoken=${getCookie('ltoken')}; ltuid=${getCookie('ltuid')};`;
} else if (document.cookie.includes('ltoken_v2=')) {
  token = `account_mid_v2=${getCookie('account_mid_v2')}; account_id_v2=${getCookie('account_id_v2')}; ltoken_v2=${getCookie('ltoken_v2')}; ltmid_v2=${getCookie('ltmid_v2')}; ltuid_v2=${getCookie('ltuid_v2')};`;
} else { 
  token = document.cookie;
}
let ask = confirm(token + '\n\nPress enter, then paste the token into your Google Apps Script Project');
if (ask) {
  copy(token);
  msg = token;
} else {
  msg = 'Cancel';
}

Well, I think I got the v2 token (although it's long as hell) but it reamains the same
image
image
image

Hoyolab reset the cookie as HTTPOnly cookie, so it's not possible to directly access or read HTTPOnly cookies using the browser's developer console or JavaScript code.
getToken.js will never work again. :(

So how do I get the cookies manually?

Hoyolab reset the cookie as HTTPOnly cookie, so it's not possible to directly access or read HTTPOnly cookies using the browser's developer console or JavaScript code. getToken.js will never work again. :(

Nevermind, I've found a way to manually get the token:

  • Go to HoYoLAB (https://www.hoyolab.com/) and log in.
  • Go to your profile page.
  • Open the developer tools (F12 or Ctrl+Shift+I).
  • Go to the "Network" tab.
  • Click on the "Preserve Log" / "Persist Logs" button.
  • 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" or "ltoken_v2" cookie value.
  • Copy the "ltuid" or "ltuid_v2" cookie value.
    Cre: https://github.com/Joshua-Noakes1/mei-cards