// ==UserScript== // @name MHBD自动签到 // @namespace https://bbs.tampermonkey.net.cn/ // @description MHBD自动签到 // @version 0.1.0 // @author gyoza // @crontab * * once * * // @grant GM_xmlhttpRequest // @grant GM_notification // @connect www.manhuabudangbbs.com // ==/UserScript== return new Promise((resolve, reject) => { const infoUrl = 'https://www.manhuabudangbbs.com/u.php'; GM_xmlhttpRequest({ method: 'GET', url: infoUrl, onload: function (resp) { const m = resp.responseText.match(/verifyhash\s*=\s*["']([a-f0-9]+)["']/i); if (!m) { GM_notification({ title: 'MHBD', text: '🔴未找到 verifyhash' }); resolve('param'); return; } const verify = m[1]; const signUrl = `https://www.manhuabudangbbs.com/jobcenter.php?action=punch&verify=${verify}`; GM_xmlhttpRequest({ method: 'POST', url: signUrl, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data: 'step=2', onload: function (r2) { const t = r2.responseText; // 1. 优先判断是否真正成功 if (t.includes('成功')) { GM_notification({ title: 'MHBD', text: '🟢打卡成功' }); resolve('ok'); } // 2. 其次判断是否已打卡 else if (t.includes('你已经打卡')) { GM_notification({ title: 'MHBD', text: '🟢今日已打卡' }); resolve('already'); } // 3. 兜底:HTTP 200 即视为完成 else { GM_notification({ title: 'MHBD', text: '🟢打卡完成' }); resolve('ok'); } }, onerror: () => { GM_notification({ title: 'MHBD', text: '🔴网络错误' }); resolve('net_err'); } }); }, onerror: () => { GM_notification({ title: 'MHBD', text: '🔴获取页面失败' }); resolve('get_fail'); } }); });