iKuuu 自动登录签到
// ==UserScript==
// @name iKuuu 自动登录签到
// @namespace http://tampermonkey.net/
// @version 1.2
// @description 自动登录iKuuu网站并完成每日签到
// @author YourName
// @match https://ikuuu.one/*
// @connect ikuuu.one
// @grant GM_xmlhttpRequest
// @grant GM_notification
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_setClipboard
// @grant GM_addStyle
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
// 配置
const LOGIN_URL = 'https://ikuuu.one/auth/login';
const CHECKIN_URL = 'https://ikuuu.one/user/checkin';
const USER_EMAIL = 'your_email@example.com'; // 替换为你的邮箱
const USER_PASSWORD = 'your_password'; // 替换为你的密码
// 显示通知
const showNotification = (message) => {
GM_notification({
title: 'iKuuu 签到结果',
text: message,
timeout: 5000
});
};
// 登录并获取Cookie
const login = async () => {
try {
const response = await new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "POST",
url: LOGIN_URL,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "https://ikuuu.one",
"Referer": "https://ikuuu.one/auth/login"
},
data: `email=${encodeURIComponent(USER_EMAIL)}&passwd=${encodeURIComponent(USER_PASSWORD)}&remember_me=on`,
onload: resolve,
onerror: reject
});
});
const result = JSON.parse(response.responseText);
if (result.ret === 1) {
return true;
} else {
showNotification(`登录失败:${result.msg}`);
return false;
}
} catch (error) {
showNotification(`登录请求失败:${error.message}`);
return false;
}
};
// 执行签到
const checkIn = async () => {
try {
const response = await new Promise((resolve, reject) => {
GM_xmlhttpRequest({
method: "POST",
url: CHECKIN_URL,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "https://ikuuu.one",
"Referer": "https://ikuuu.one/user"
},
onload: resolve,
onerror: reject
});
});
const result = JSON.parse(response.responseText);
if (result.ret === 1) {
showNotification(`签到成功!本月流量:${result.trafficInfo['lastUsedTraffic']}`);
} else {
showNotification(`签到失败:${result.msg}`);
}
} catch (error) {
showNotification(`签到请求失败:${error.message}`);
}
};
// 自动执行登录和签到
const autoCheckIn = async () => {
const lastCheckIn = GM_getValue('lastCheckIn', 0);
const today = new Date().toDateString();
// 如果今天已经签到过,则不再执行
if (new Date(lastCheckIn).toDateString() === today) {
console.log('今天已经签到过了');
return;
}
const isLoggedIn = await login();
if (isLoggedIn) {
await checkIn();
GM_setValue('lastCheckIn', Date.now()); // 记录本次签到时间
}
};
// 页面加载完成后自动执行签到
window.addEventListener('load', () => {
autoCheckIn();
});
// 注册菜单命令(可选)
GM_registerMenuCommand("手动执行签到", autoCheckIn);
})();