// ==UserScript== // @name WONG公益站自动签到 // @namespace https://scriptcat.org/en/script-show-page/5020 // @version 0.1.2 // @description WONG公益站自动签到,每天自动签到一次,失败则通知 // @author Wilsons // @crontab * * once * * // @grant GM_notification // @grant GM_xmlhttpRequest // @grant GM_getValue // ==/UserScript== /* ==UserConfig== config: url: title: WONG公益站主域名 description: 仅填写主域名即可,比如:https://xxxx.com type: text default: min: 1 max: 1024 password: false userId: title: 您的用户ID description: 可在WONG公益站-个人设置的顶部查看 type: text default: min: 1 max: 64 password: false cookies: title: 您的Cookies description: 控制台-应用-Cookie中查看 type: text default: min: 1 max: 1024 password: false ==/UserConfig== */ return new Promise((resolve, reject) => { //$$('.semi-card-body [data-popupid]') let cookies = GM_getValue('config.cookies') || ''; if(!cookies.includes('session=')) cookies = 'session=' + cookies; const userId = GM_getValue('config.userId') || ''; let url = GM_getValue('config.url') || ''; const domainRegex = new RegExp('^(https?://[^/]+)', 'i'); const match = url.match(domainRegex); url = match ? match[1] : ''; if(!userId || !cookies.replace('session=', '') || !url || !url.startsWith('http')) { GM_notification("签到失败!用户ID、cookies或主域名填写有误!"); resolve(); return; } GM_xmlhttpRequest({ method: "POST", url: url + "/api/user/checkin", headers: { "accept": "application/json, text/plain, */*", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8", "cache-control": "no-store", "content-length": "0", "Cookie": cookies, "new-api-user": userId, "origin": url, "pragma": "no-cache", "priority": "u=1, i", "referer": url + "/console/topup", "sec-ch-ua": '"Google Chrome";v="143", "Chromium";v="143", "Not A(Brand";v="24"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"macOS"', "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36" }, onload: function(response) { console.log("签到成功:", response.responseText); try { let json = JSON.parse(response.responseText); if(json.success !== true) { GM_notification("签到失败!" + (json?.message || '')); } } catch (e) { console.error("签到失败!" + (error?.message || '')); } //GM_notification("签到结果: " + response.responseText); }, onerror: function(error) { console.error("签到失败:", error); GM_notification("签到失败!" + (error?.message || '')); } }); resolve(); });