自动签到脚本,从本地读取上次签到时间并判断是否是新的一天进行签到
当前为
// ==UserScript==
// @name 共创世界(CCW)自动签到
// @namespace https://greasyfork.org/zh-CN/scripts/共创世界(CCW)自动签到
// @version 1.0
// @description 自动签到脚本,从本地读取上次签到时间并判断是否是新的一天进行签到
// @author kukemc
// @match *ccw.site
// @grant GM_setValue
// @grant GM_getValue
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 从本地读取上次签到时间
var lastCheckinTime = GM_getValue('lastCheckinTime');
// 获取当前日期
var currentDate = new Date().toLocaleDateString();
console.log('开始判断签到');
// 判断是否是新的一天
if (lastCheckinTime !== currentDate) {
console.log('执行签到');
// 执行签到操作
var token = document.cookie
.split('; ')
.find(row => row.startsWith('token='))
.split('=')[1];
var headers = {
'Content-Type': 'application/json',
'token': token
};
var payload = {
'scene': 'HOMEPAGE'
};
// 发送签到请求
fetch('https://community-web.ccw.site/study-community/check_in_record/insert', {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => {
console.log(data); // 控制台输出签到结果
// 将签到时间写入本地存储
GM_setValue('lastCheckinTime', currentDate);
})
.catch(error => console.error(error));
} else {
console.log("用户已签到过"); // 控制台输出不是新的一天
}
})();