// ==UserScript== // @name iKuuu自动签到(ScriptCat版) // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.4 // @description 每日执行自动签到 // @author d3f4ult // @crontab * * once * * // @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() { if (check_count !== 0) setTimeout(() => {}, 5000) 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 }) resolve('签到成功') } else { GM_notification({ title: "iKuuu", text: `签到失败:${result.msg}` }) reject('签到失败') } }, onerror: () => { check_count++ auto_check() if (check_count === 7) { GM_notification({ title: "iKuuu", text: "自动签到失败次数已达上限,请查看日志检查原因!", onclick: (id) => { GM_openInTab(`${domain}`); GM_closeNotification(id); }, }) reject('重试签到次数已达上限') } } }) } auto_check() });