Greasy Fork

Greasy Fork is available in English.

52论坛自动签到助手_免打扰

打开论坛自动签到, 无其他提示

当前为 2018-11-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @icon         https://www.52pojie.cn/favicon.ico
// @name         52论坛自动签到助手_免打扰
// @namespace    https://zfdev.com/
// @version      0.1
// @description  打开论坛自动签到, 无其他提示
// @author       ZFDev
// @match        *://www.52pojie.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function saveDate(){
        localStorage.setItem('autoSign',new Date().toDateString());
    }
    function isTody(){
        var lastSignDate = localStorage.getItem('autoSign');
        if(lastSignDate){
            return new Date(lastSignDate).toDateString() === new Date().toDateString();
        }else{
            return false;
        }
    }
    const s = {
        a: "正在自动签到...",
        b: "本期您已申请过此任务",
        c: "您已经签到了!",
        d: "成功",
        f: "签到成功!",
        g: "签到失败!",
        h: '<img src="https://www.52pojie.cn/static/image/common/wbs.png" class="qq_bind" align="absmiddle" alt="">',
        i: "自动签到中..",
        j: '#hd .wp #um p > a[href*="home.php?mod=task&do=apply&id=2"]',
        k: 'home.php?mod=task&do=apply&id=2',

    }
    function autoSign(num) {
        if (!isTody()){
            let a = document.querySelectorAll(s.j);
            if(a){
                a.text = s.i;
                try{
                    var x = new Ajax();

                }catch(e){
                    if(!num || num < 2){
                        setTimeout(function(){
                            autoSign(num+1);
                        },2000);
                    }
                    return;
                }
                x.getHTML(s.k , function(res) {
                    console.log(s.a);
                    if(res.indexOf(s.b)>0){
                        console.log(s.c);
                        saveDate();
                    }else if(res.indexOf(s.d)>0){
                        console.log(s.f);
                        saveDate();
                        a.innerHTML = s.h;
                    }else{
                        console.log(s.g);
                    }

                });
            }
        }
    }
})();