Closed takeimhk closed 1 year ago
If you mean that you want only to do daily check-in in Genshin Impact using only Google Apps Script, then I'm pretty sure it will be easy to do
yes, only daily checkin and multiple account, and thanks
sorry for the delay, but here's the code as your requested
const accounts = [
// if you can't find ltoken try to find ltoken_v2, same as ltuid
"ltoken=asd123bcd; ltuid=123321",
"ltoken_v2=dsa123xdxd; ltuid_v2=3214321"
];
const requestHeaders = {
"User-Agent": "Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Mobile Safari/537.36",
"x-rpc-app_version": "2.34.1",
"x-rpc-client_type": "4"
};
async function signIn (account) {
const url = "https://sg-hk4e-api.hoyolab.com/event/sol/sign";
const headers = {
...requestHeaders,
cookie: account
};
const res = UrlFetchApp.fetch(url, {
method: "POST",
headers,
payload: JSON.stringify({
act_id: "e202102251931481"
})
});
if (res.getResponseCode() !== 200) {
throw new Error(`Failed to sign in. Response code: ${res.getResponseCode()}`);
}
const data = JSON.parse(res.getContentText());
if (data.data === null) {
console.log(data.message);
}
if (data.message === "OK") {
console.log(`Successfully signed in.`);
}
}
async function run () {
for (const account of accounts) {
try {
await signIn(account);
}
catch (e) {
console.error(e);
}
}
}
If you have any question feel free to ask here
should i do the same thing as the star rail one? like add script cookie?
and error
For this specific code, no, you just put your cookie at the accounts
array, I already put instructions there, or you could just paste the whole cookie there and it should be work fine, just remember to hide it next time you're going to upload the image
i put "ltoken=xxxxx" and "ltuid=xxxxx" from genshin daily checkin website document.cookie, and the same error appear
Error
Exception: Attribute provided with invalid value: Header:null
signIn @ Code.gs:20
ok, i just fixed it, by copy paste my document.cookie to the account
async function signIn (account) {
const url = "https://sg-hk4e-api.hoyolab.com/event/sol/sign";
const headers = {
...requestHeaders,
cookie: "**document.cookie** <<<here"
};
Thanks again
hey, i have a request, i want to do genshin impact to with APPS SCRIPT google, can you guys make it?