本帖最后由 2325924068 于 2024-9-25 10:11 编辑
废话少说直接上代码。
下载 FeHelper
谷歌示例:安装 油猴插件。按截图配置即可。每天进到本站自动签到。
[JavaScript] 纯文本查看 复制代码 try {
// 当前日期
let date = new Date(), year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate();
// 日期状态
let date_state = year + '' + month + '' + day;
// 登录状态
let login_state = document.getElementById('lsform') ? false : true;
// localStorage 键
let localKey = 'signin_state_' + date_state;
// 签到状态
let signin_state = false;
// 删除掉之前的签到记录
for (let i = 0, len = localStorage.length; i < len; i++) {
let key = localStorage.key(i);
if (key && key.indexOf('signin_state_') > -1 && (key != localKey)) {
localStorage.removeItem(key);
console.log('已删除之前签到记录:' + key);
}
}
// 签到数据
let signin_Storage = localStorage.getItem(localKey);
signin_state = signin_Storage == null ? false : JSON.parse(signin_Storage);
console.log('签到状态:', signin_state);
console.log('登录状态:', login_state);
if (login_state && signin_state == false) {
signin();
}
// 签到
async function signin() {
console.log('--开始签到--');
if (await signin_fun()) {
console.log('用户签到成功');
} else {
console.log('用户签到失败');
}
// 浏览空间
let len = 10;
for (let i = 1; i <= len; i++) {
let state = await state_fun(location.origin + '/home.php?mod=space&uid=' + i);
if (state == false) len++;
console.log('浏览用户:' + i + (state ? ' 成功' : ' 失败'));
}
// 签到完成
localStorage.setItem(localKey, true);
console.log('--签到完成--');
}
// 签到请求函数
function signin_fun() {
return new Promise((resolve, reject) => {
const scriptHtml = document.querySelectorAll("script");
let formhash = "";
for (let i = 0, len = scriptHtml.length; i < len; i++) {
if (scriptHtml[i].src.indexOf("formhash=") > -1) {
const urlParams = new URLSearchParams(scriptHtml[i].src.split('?')[1]);
formhash = urlParams.get('formhash');
break;
}
}
if (!formhash) return resolve(false);
$.ajax({
url: "/plugin.php?id=dc_signin:sign&inajax=1",
type: "post",
data: { formhash, signsubmit: true, handlekey: "signin", emotid: 7, content: "自动签到!星辰曲径" },
dataType: "html",
success: function (res) {
console.log("签到请求状态:", res);
if (res.indexOf("已经签过") > -1) {
resolve(false);
} else {
resolve(true);
}
},
error: function (error) {
resolve(false);
}
});
});
}
async function state_fun(url) {
return new Promise((resolve, reject) => {
$.ajax({
url,
type: 'get',
dataType: 'html',
success: function (res) {
resolve(true);
},
error: function (errpr) {
reject(false);
}
})
})
}
} catch (error) {
console.log(error);
} |