头顶冒火自动签到
// ==UserScript==
// @name 头顶冒火自动签到
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.0.5
// @description 启动浏览器时《头顶冒火》自动签到,请使用脚本猫
// @author Thousand_Star
// @license MIT
// @background
// @crontab * 8-23 once * *
// @grant GM_xmlhttpRequest
// @grant GM_log
// @grant GM_notification
// @icon https://burn.hair/favicon.ico
// @connect burn.hair
// ==/UserScript==
function notify(message) {
GM_notification({
title: '头顶冒火自动签到',
text: message
});
}
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 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
// 似乎不是这么获取的,先写死500000
// const x = localStorage.getItem('display_in_currency')
const money = (token / 500000).toFixed(2)
GM_log("剩余token:" + token + "------剩余美元:" + money)
resolve(money);
},
onerror: (error) => {
reject(error);
}
});
});
}
});