Skip to content

Instantly share code, notes, and snippets.

@d1y
Created May 29, 2025 03:12
Show Gist options
  • Save d1y/2481e988461ac390bce2f4e7f0a0e637 to your computer and use it in GitHub Desktop.
Save d1y/2481e988461ac390bce2f4e7f0a0e637 to your computer and use it in GitHub Desktop.
IKunn
#!/usr/bin/env node
async function login(email, password) {
try {
const formData = new URLSearchParams({
host: 'ikuuu.one',
email: email,
passwd: password,
remember_me: 'on',
code: ''
});
const response = await fetch("https://ikuuu.one/auth/login", {
method: "POST",
headers: {
"accept": "application/json, text/javascript, */*; q=0.01",
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"x-requested-with": "XMLHttpRequest",
},
body: formData.toString()
});
const setCookieHeader = response.headers.get('set-cookie');
if (!setCookieHeader) {
throw new Error('No set-cookie header found');
}
const cookieParts = setCookieHeader.split(', ')
.filter(part => /^(uid|email|key|ip|expire_in)=/.test(part))
.map(part => part.split(';')[0]);
const cookie = cookieParts.join('; ');
// console.log('Generated cookie:', cookie);
return cookie;
} catch (error) {
console.error(`Login failed for ${email}:`, error.message);
return null;
}
}
async function checkin(cookies) {
try {
const response = await fetch("https://ikuuu.one/user/checkin", {
headers: {
"accept": "application/json, text/javascript, */*; q=0.01",
"x-requested-with": "XMLHttpRequest",
"cookie": cookies,
},
method: "POST"
});
const data = await response.json();
return data;
} catch (error) {
console.error('Checkin failed:', error);
return null;
}
}
async function getInfo(cookies) {
try {
const response = await fetch("https://ikuuu.one/user", {
headers: {
"accept": "application/json, text/javascript, */*; q=0.01",
"x-requested-with": "XMLHttpRequest",
"cookie": cookies,
},
method: "GET"
});
const html = await response.text()
const info = html.match(/trafficDountChat\(([^)]+)\)/)[1].split(",").map(item=> item.trim().replaceAll('\'',''))
return {
lastUsed: info[0],
todayUsed: info[1],
unUsed: info[2],
// last100: info[3],
// today100: info[4],
// unuse100: info[5],
}
} catch (error) {
console.error('Get info failed:', error);
return null;
}
}
async function processAccount(account) {
const cookies = await login(account.email, account.password);
if (!cookies) {
console.log(`Failed to login for account: ${account.email}`);
return;
}
const checkinResult = await checkin(cookies);
if (checkinResult) {
// console.log(checkinResult.msg)
return cookies
}
console.log('已自动签到')
return cookies
}
async function main() {
const account = { email: process.env.EMAIL, password: process.env.PASSWORD }
const cx = await processAccount(account)
const info = await getInfo(cx)
console.log(`今日已用: ${info.todayUsed}`)
console.log(`本月已用: ${info.lastUsed}`)
console.log(`剩余流量: ${info.unUsed}`)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment