Skip to content

Instantly share code, notes, and snippets.

@blueaxis
Last active December 24, 2023 07:27
Show Gist options
  • Save blueaxis/77847e63522fc747450ef718b68719ee to your computer and use it in GitHub Desktop.
Save blueaxis/77847e63522fc747450ef718b68719ee to your computer and use it in GitHub Desktop.
Script to obtain token and ID from Hoyolab
Script to obtain token and ID from Hoyolab
(()=>{if(document.cookie.includes('ltoken')&&document.cookie.includes('ltuid')){const e=document.createElement('input');try{e.value=`${t('ltuid')},${t('ltoken')}`}catch(o){console.warn('readCookie is still undefined');const t=e=>{const o=`; ${document.cookie}`.split(`; ${e}=`);if(2===o.length)return o.pop().split(';').shift()};e.value=`${t('ltuid')},${t('ltoken')}`}document.body.appendChild(e),e.select(),navigator.clipboard.writeText(e.value),prompt('Success! Token is copied to clipboard. You may manually copy the token below:\n',e.value)}else alert('Token has expired. Please signin again.')})();
(() => {
if (document.cookie.includes("ltoken") && document.cookie.includes("ltuid")) {
const input = document.createElement("input");
try {
input.value = `${readCookie("ltuid")},${readCookie("ltoken")}`;
} catch (o) {
console.warn("readCookie is still undefined");
const readCookie = (key) => {
const cookies = `; ${document.cookie}`.split(`; ${key}=`);
if (2 === cookies.length) return cookies.pop().split(";").shift();
};
input.value = `${readCookie("ltuid")},${readCookie("ltoken")}`;
}
document.body.appendChild(input),
input.select(),
navigator.clipboard.writeText(input.value),
prompt(
"Success! Token is copied to clipboard. You may manually copy the token below:\n",
input.value
);
} else alert("Token has expired. Please signin again.");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment