NodeSeek自动签到
// ==UserScript==
// @name NodeSeek自动签到
// @namespace https://bbs.tampermonkey.net.cn/
// @version 1.0.4-1
// @description NodeSeek自动签到脚本,默认:试试手气
// @author bmqy
// @crontab * 8 once * *
// @grant GM_xmlhttpRequest
// @grant GM_log
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_notification
// @connect www.nodeseek.com
// @background
// ==/UserScript==
/* ==UserConfig==
配置:
method:
title: 签到方式
description: 选择签到方式,默认:试试手气
type: select
default: '试试手气'
values: ['试试手气','稳定保底']
stats:
title: 统计分析
description: 统计最近每月的每7、30天签到数据,并与稳定签到对比
type: checkbox
default: false
==/UserConfig==*/
return new Promise((resolve, reject) => {
let method = GM_getValue('配置.method');
let stats = GM_getValue('配置.stats');
let storageKey = '缓存.list';
let api = 'https://www.nodeseek.com/api/attendance';
if(!method || method === '试试手气'){
api = `${api}?random=true`;
}
GM_xmlhttpRequest({
method: 'POST',
url: api,
onload: function (xhr) {
let response = JSON.parse(xhr.response);
if (xhr.status == 200) {
let storageData = GM_getValue(storageKey, []);
let {success, message, gain, current} = response;
if (success) {
if(storageData.length >= 31){
storageData.splice(0, 1)
}
let msg = message;
storageData.push(gain);
GM_setValue(storageKey, storageData);
let theDate = new Date().getDate();
stats && [7, 30].forEach((e)=>{
if(storageData.length>=e && theDate%e===0){
let s = 0;
let a = e * 5;
for(let i=storageData.length-1; i>=storageData.length-e; i--){
s += storageData[i];
}
msg = `+${gain}🍗,近${e}日共${s}:比保底值${s>a ? '多'+(s-a) : '少'+(a-s)}`
}
})
GM_log(msg)
GM_notification(msg);
resolve(msg);
} else {
GM_notification(message);
GM_log(message)
}
} else {
GM_notification({
title: 'NodeSeek自动签到',
text: response.message,
});
reject(response.message);
}
},
onerror: function(err){
GM_log(err)
}
});
});