// ==UserScript== // @name iKuuu自动签到(ScriptCat版) // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description 每日中午 12 点执行 // @author d3f4ult // @crontab 0 12 * * * // @grant GM_xmlhttpRequest // @grant GM_log // @grant GM_notification // @grant GM_openInTab // @grant GM_closeNotification // @homepage https://ikuuu.one // ==/UserScript== /* ######################################################### */ /* #██████╗ ██████╗ ███████╗██╗ ██╗██╗ ██╗██╗ ████████╗# */ /* #██╔══██╗╚════██╗██╔════╝██║ ██║██║ ██║██║ ╚══██╔══╝# */ /* #██║ ██║ █████╔╝█████╗ ███████║██║ ██║██║ ██║ # */ /* #██║ ██║ ╚═══██╗██╔══╝ ╚════██║██║ ██║██║ ██║ # */ /* #██████╔╝██████╔╝██║ ██║╚██████╔╝███████╗██║ # */ /* #╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ # */ /* ######################################################### */ return new Promise((resolve, reject) => { const domain = "https://ikuuu.one" const check_count = 0 // 检查是否登录 GM_xmlhttpRequest({ method: "GET", url: `${domain}/user`, onload: function (response) { if (response.finalUrl == `${domain}/auth/login`) { GM_notification({ title: "iKuuu", text: "请点击,登陆后重新运行脚本", onclick: (id) => { GM_openInTab(`${domain}/auth/login`); GM_closeNotification(id); } }); reject("未登录"); } else if (xhr.finalUrl == "https://ikuuu.eu/user") { // } else { reject("网页跳转向了一个未知的网址"); } }, onerror: function (error) { reject('获取Cookie失败:' + error); } }); // 自动签到 function auto_check() { setTimeout(() => { GM_xmlhttpRequest({ method: "POST", url: `${domain}/user/checkin`, timeout: 5000, onload: (response) => { let result = JSON.parse(response.responseText) if (result.ret === 1) { GM_notification({ title: "iKuuu", text: `签到成功:${result.msg}`, timeout: 10000 }) } else { GM_notification({ title: "iKuuu", text: `签到失败:${result.msg}` }) } }, ontimeout: () => { GM_log("请求超时,再试一次。", "info") check_count++ auto_check() }, onabort: () => { GM_log("请求终止,再试一次。", "info") check_count++ auto_check() }, onerror: () => { check_count++ auto_check() if (check_count === 7) { GM_notification({ title: "iKuuu", text: "每日签到请求发送失败!", onclick: (id) => { GM_openInTab(`${domain}`); GM_closeNotification(id); }, }) reject('重试签到次数已达上限') } } }) }, 5000) } auto_check() });