PTT签到脚本
https://www.pttime.org/forums.php?action 在这里找到cookie
uid 在个人中心查看
const axios = require("axios");
// 在此处替换为自己的 cookie 和 uid
const cookie = ';
const uid = '';
const headers = {
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
cookie: cookie,
dnt: "1",
pragma: "no-cache",
priority: "u=0, i",
referer: "https://www.pttime.org/",
"sec-ch-ua": '"Chromium";v="127", "Not)A;Brand";v="99"',
"sec-ch-ua-arch": '"arm"',
"sec-ch-ua-bitness": '"64"',
"sec-ch-ua-full-version": '"127.0.6533.89"',
"sec-ch-ua-full-version-list": '"Chromium";v="127.0.6533.89", "Not)A;Brand";v="99.0.0.0"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-model": '""',
"sec-ch-ua-platform": '"macOS"',
"sec-ch-ua-platform-version": '"15.0.0"',
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"user-agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
};
const url = `https://www.pttime.org/attendance.php?type=sign&uid=${uid}`;
const checkIn = () => {
axios
.get(url, { headers })
.then((response) => {
const totalSignMatch = response.data.match(/总签到:(\d+) 天/);
const magicMatch = response.data.match(/获得魔力值:<b>(\d+)<\/b>/);
if (totalSignMatch && magicMatch) {
const totalSign = totalSignMatch[1];
const magic = magicMatch[1];
console.log(`签到成功!总签到: ${totalSign} 天, 获得魔力值: ${magic}`);
} else {
console.log("未找到相关信息,请检查响应内容。");
}
})
.catch((error) => {
console.error("请求失败:", error);
});
};
setInterval(() => {
const now = new Date();
const currentHour = now.getHours();
if (currentHour === 6) {
let newZDate = new Date();
let strTime = `${newZDate.getFullYear()}-${(newZDate.getMonth() + 1) > 9 ? (newZDate.getMonth() + 1) : '0' + (newZDate.getMonth() + 1)}-${newZDate.getDate() > 9 ? newZDate.getDate() : '0' + newZDate.getDate()} ${newZDate.getHours() > 9 ? newZDate.getHours() : '0' + newZDate.getHours()}:${newZDate.getMinutes() > 9 ? newZDate.getMinutes() : '0' + newZDate.getMinutes()}:${newZDate.getSeconds() > 9 ? newZDate.getSeconds() : '0' + newZDate.getSeconds()}`;
console.log(strTime);
checkIn();
}
}, 20 * 60 * 1000);