// ==UserScript== // @name 鱼C论坛签到 // @namespace https://bbs.tampermonkey.net.cn/ // @description 鱼C论坛签到(论坛状态是登录完成) // @version 0.1.0 // @author shuaima // @crontab * * once * * // @grant GM_xmlhttpRequest // @grant GM_notification // @connect fishc.com.cn // ==/UserScript== return new Promise((resolve, reject) => { // 使用GM_xmlhttpRequest获取页面内容,并提取id为JD_sign的标签的href属性 // 替换为你想要请求的URL var targetUrl = 'https://fishc.com.cn/plugin.php?id=k_misign:sign'; // 读取 签到按钮 链接 GM_xmlhttpRequest({ method: 'GET', url: targetUrl, onload: function(response) { // 解析响应内容 var doc = new DOMParser().parseFromString(response.responseText, 'text/html'); // 按钮 id var link = doc.querySelector('#JD_sign'); var title = "鱼C论坛"; // 网址 非空 if (link && link.href) { // 在控制台输出或在页面上显示链接 console.log('找到链接:', link.href); // 访问 签到网址 GM_xmlhttpRequest({ method: 'GET', url: link.href, onload: function(getResponse) { // 签到 成功 检测 let pageContent = getResponse.responseText; // 签到 成功 字符串 let targetString = "CDATA[]"; // 使用indexOf检查字符串是否存在 if (pageContent.indexOf(targetString) > -1) { GM_notification({ title: title, text: '🟢签到成功', }); resolve('签到成功:存在'); } else { GM_notification({ title: title, text: '🟢签到出错', }); resolve('签到出错:不存在'); } }, onerror: function(error) { console.error('请求失败:', error); } }); resolve("read_link_ok") } else { // 获取 签到链接 失败 GM_notification({ title: title, text: '🟢重复签到', }); resolve('read_link_error'); } }, onerror: function(error) { console.error('请求失败:', error); } }); });