// ==UserScript== // @name 头顶冒火每日8点2分自动签到 // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.0.7 // @description 浏览器打开时每日8点2分《头顶冒火》自动签到,请使用脚本猫 // @author xuejc21cn // @license MIT // @background // @grant GM_xmlhttpRequest // @grant GM_log // @grant GM_notification // @icon // @connect burn.hair // ==/UserScript== function scheduleCheckIn() { const now = new Date(); const next802AM = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 8, 2, 0, 0); if (now >= next802AM) { next802AM.setDate(next802AM.getDate() + 1); } const timeUntilNext802AM = next802AM - now; setTimeout(() => { checkIn().then(() => { scheduleCheckIn(); // Schedule the next check-in after successful check-in }).catch(() => { scheduleCheckIn(); // Schedule the next check-in even if there was an error }); }, timeUntilNext802AM); } function checkIn() { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'POST', url: 'https://burn.hair/api/user/check_in', headers: { "Content-Type": "application/json;charset=UTF-8" }, responseType: "json", onload: (xhr) => { const message = xhr.response.message; GM_log(message); getUserMoney().then((money) => { money = "剩余美元:" + money + "$"; notify(message + "\n" + money); resolve(); }).catch((error) => { reject(error); }); }, onerror: (error) => { reject(error); } }); }); } function notify(message) { GM_notification({ title: '头顶冒火自动签到', text: message }); } function getUserMoney() { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'GET', url: 'https://burn.hair/api/user/self', headers: { "Content-Type": "application/json;charset=UTF-8" }, responseType: "json", onload: (xhr) => { const token = xhr.response.data.quota; const money = (token / 500000).toFixed(2); GM_log("剩余token:" + token + "------剩余美元:" + money); resolve(money); }, onerror: (error) => { reject(error); } }); }); }