// ==UserScript== // @name 源社区自动签到 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.1.0 // @description 源社区每日自动签到脚本 // @author 水友 // @crontab 1-59 0-23 once * * // @grant GM_xmlhttpRequest // @grant GM_notification // @connect ysqbbs.com // ==/UserScript== return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'GET', url: 'https://ysqbbs.com/k_misign-sign.html', onload: function (xhr) { if (xhr.status == 200) { // 匹配签到链接的正则表达式 const regex = /id="JD_sign"[^>]*href="([^"]*)"/i; let m = regex.exec(xhr.responseText); if (!m || !m[1]) { GM_notification('源社区可能已经签过到了'); resolve('源社区可能已经签过到了'); return; } // 处理HTML实体并构造完整URL const urlPath = m[1] .replace(/&/g, '&') // 转换HTML实体 .replace(/^\/?/, '/'); // 确保路径格式正确 GM_xmlhttpRequest({ method: 'GET', url: 'https://ysqbbs.com' + urlPath, onload: function (xhr) { if (xhr.status >= 200 && xhr.status < 400) { GM_notification({ title: '源社区签到成功', text: '自动签到已完成', timeout: 2000 }); resolve('源社区签到成功'); } else { GM_notification({ title: '源社区签到异常', text: `状态码: ${xhr.status}`, timeout: 2500 }); resolve('源社区签到异常'); } }, onerror: function (err) { GM_notification({ title: '请求失败', text: err.error, timeout: 3000 }); resolve('网络错误'); } }); } else { GM_notification({ title: '源社区自动签到 - ScriptCat', text: '源社区自动签到失败,账号未登录,请先登录', }); reject('源社区账号未登录'); } } }); });