Zodgame 无感知自动签到
当前为
// ==UserScript==
// @name Zodgame 自动签到
// @icon https://zodgame.xyz/favicon.ico
// @namespace https://github.com/NPC2000
// @version 1.0.1
// @description Zodgame 无感知自动签到
// @author NPC
// @match https://zodgame.xyz/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
const today = new Date().toISOString().split('T')[0]; // 获取今天的日期 (格式: YYYY-MM-DD)
// 获取Cookie中qhMq_2132_lastcheckfeed的值,并提取uid
const cookies = document.cookie.split('; ');
let uid = null;
cookies.forEach(cookie => {
if (cookie.startsWith('qhMq_2132_lastcheckfeed=')) {
const cookieValue = cookie.split('=')[1];
uid = cookieValue.split('%')[0]; // 提取uid,位于%之前
}
});
if (!uid) {
console.error('无法获取用户UID,停止签到');
return;
}
const lastSignInDateKey = `lastSignInDate_${uid}`; // 为每个用户使用独立的签到日期key
const lastSignInDate = localStorage.getItem(lastSignInDateKey); // 获取该用户的上次签到日期
// 检查今天是否已经签到过
if (lastSignInDate === today) {
console.log(`用户 ${uid} 今天已经签到过了,跳过签到操作`);
return; // 今天已经签到过,退出脚本
}
// 如果没有签到过,则继续执行签到操作
console.log(`用户 ${uid} 尚未签到,开始签到操作`);
// 自动获取formhash
const formhashElement = document.querySelector('input[name="formhash"]');
let formhash = '';
if (formhashElement) {
formhash = formhashElement.value;
console.log('Formhash:', formhash); // 打印formhash以检查获取是否成功
} else {
console.error('未能找到formhash元素');
return;
}
// 定义签到所需的数据
let formData = new URLSearchParams();
formData.append('formhash', formhash); // 使用自动获取的formhash
formData.append('qdxq', 'ng'); // 'ng' 是签到的参数
// 发送POST请求
fetch('https://zodgame.xyz/plugin.php?id=dsu_paulsign:sign&operation=qiandao&infloat=1&inajax=1', {
method: 'POST',
body: formData // 浏览器自动处理所有头部信息
})
.then(response => response.text()) // 解析为文本形式
.then(data => {
console.log("签到请求已发送");
console.log(data); // 打印返回的响应,以便检查是否成功
// 如果签到成功,将签到日期存储到localStorage
if (data.includes('已经签到')) {
localStorage.setItem(lastSignInDateKey, today); // 存储该账号今天的签到日期
console.log(`用户 ${uid} 签到成功,今天的签到状态已更新`);
}
})
.catch((error) => {
console.error('签到请求失败:', error);
});
})();