// ==UserScript==
// @name 🔥任何网页下完成🔥52破解论坛自动签到
// @namespace https://greasyfork.org/zh-CN/users/412790
// @version 1.0.1.0
// @description 在任何网页下完成吾爱破解论坛签到, 使用了tampermonkey进行跨域请求, 弹出提示请选择"总是允许域名"
// @require https://cdn.jsdelivr.net/npm/sweetalert2@9
// @author Permission
// @match http://*/*
// @match https://*/*
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_openInTab
// @noframes
// ==/UserScript==
/* global Swal */
const url = "https://www.52pojie.cn/home.php?mod=task&do=apply&id=2"; // https://www.52pojie.cn/home.php?mod=task&do=draw&id=2
const checkNewDay = (ts) => {
const t = new Date(ts);
t.setMinutes(t.getMinutes());
t.setHours(0, 0, 0, 0);
const d = new Date();
d.setMinutes(t.getMinutes());
return (d - t > 86400e3);
};
const sign = () => {
if (GM_getValue("notified")) {
sendRequest();
} else {
Swal.fire(`由于脚本使用了tampermonkey进行跨域请求, 弹出提示请选择"总是允许域名"`).then(() => {
GM_setValue("notified", true);
sendRequest();
});
}
};
const sendRequest = () => {
GM_xmlhttpRequest({
method: "GET",
url: url,
timeout: 10e3,
onload: response => {
response = response.response;
if (response.match("任务已完成") !== null) {
Swal.fire({
icon: 'success',
title: '52破解论坛自动签到',
html: `<strong>成功!</strong>`
});
GM_setValue("ts", Date.now());
} else if (response.match("您已申请过此任务") !== null) {
Swal.fire({
icon: 'warning',
title: '52破解论坛自动签到',
text: '您已经签到过了!'
});
GM_setValue("ts", Date.now());
} else if (response.match("您需要先登录才能继续本操作") !== null) {
Swal.fire({
icon: 'error',
title: '52破解论坛自动签到',
text: '您需要先登录才能继续本操作!'
});
} else {
console.log(response);
Swal.fire({
icon: 'error',
title: '52破解论坛自动签到',
text: '未知返回信息❗ 请打开控制台查看详情。',
cancelButtonText: '取消',
confirmButtonText: '手动打开',
focusConfirm: true,
showCancelButton: true,
allowOutsideClick: false,
allowEscapeKey: false
}).then(res => {
if (res.isConfirmed) {
GM_openInTab(url, {
loadInBackground: true
});
}
Swal.fire({
icon: 'info',
title: '52破解论坛自动签到',
text: '今日是否不再尝试签到?',
cancelButtonText: '否',
confirmButtonText: '是',
focusConfirm: true,
showCancelButton: true,
allowOutsideClick: false,
allowEscapeKey: false
}).then(res => {
if (res.isConfirmed) {
GM_setValue("ts", Date.now());
}
});
});
}
},
onerror: function () {
Swal.fire({
icon: 'error',
title: '52破解论坛自动签到',
text: '请求签到时发生错误, 请检查网络或代理, 防火墙等',
});
}
});
};
window.onload = () => {
if (!window.location.href.match("52pojie.cn") && (!GM_getValue("ts") || checkNewDay(GM_getValue("ts")))) {
sign();
}
};