Pojie52_TimeDown

吾爱破解回帖倒计时

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Pojie52_TimeDown
// @namespace    Pojie52_TimeDown
// @version      1.3
// @description  吾爱破解回帖倒计时
// @author       Pwnint32
// @match        https://www.52pojie.cn/thread*
// @include      https://www.52pojie.cn/forum.php?mod=viewthread*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant        GM_addElement
// ==/UserScript==

var PostLimitTime = 40;
var PostLimitEndTime = 0;

// 对回帖下方的头像处插入提示节点
function addTimeLabel() {
    var replyAvatar = document.querySelector('.avatar.avtm');

    if (replyAvatar) {
        GM_addElement(
            replyAvatar,
            "div", {
                class: "avatar avtm",
                id: "timeDown",
                style: "text-align:center;font-size:16px;color:red",
                textContent: "允许回帖"
            }
        );
    }
}

function injectReplySubmit() {
    var fastSubmit = document.querySelector("#fastpostsubmit");
    var postSubmit = document.querySelector("#postsubmit");
    var timeDown = document.querySelector("#timeDown");

    if (fastSubmit) {
        fastSubmit.onclick = function () {

            if (timeDown && timeDown.textContent == "允许回帖") {
                PostLimitTime = 40;
                // 设置倒计时
                var interval_fast_click = setInterval(function () {
                    if (PostLimitTime > 0) {
                        timeDown.textContent = "剩余:" + PostLimitTime + "秒";
                        PostLimitTime--;
                    } else {
                        clearInterval(interval_fast_click); // 停止倒计时
                        timeDown.textContent = "允许回帖";
                    }
                }, 1000); // 每秒更新一次
            }

        };

        if (event.ctrlKey && event.keyCode == 13) {

            if (timeDown && timeDown.textContent == "允许回帖") {
                PostLimitTime = 40;
                // 设置倒计时
                var interval_fast_event = setInterval(function () {
                    if (PostLimitTime > 0) {
                        timeDown.textContent = "剩余:" + PostLimitTime + "秒";
                        PostLimitTime--;
                    } else {
                        clearInterval(interval_fast_event); // 停止倒计时
                        timeDown.textContent = "允许回帖";
                    }
                }, 1000); // 每秒更新一次
            }
        }
    }

    if (postSubmit) {
        postSubmit.onclick = function () {
            if (timeDown && timeDown.textContent == "允许回帖") {
                PostLimitTime = 40;
                // 设置倒计时
                var interval_post_click = setInterval(function () {
                    if (PostLimitTime > 0) {
                        timeDown.textContent = "剩余:" + PostLimitTime + "秒";
                        PostLimitTime--;
                    } else {
                        clearInterval(interval_post_click); // 停止倒计时
                        timeDown.textContent = "允许回帖";
                    }
                }, 1000); // 每秒更新一次
            }
        };
        if (event.ctrlKey && event.keyCode == 13) {

            if (timeDown && timeDown.textContent == "允许回帖") {
                PostLimitTime = 40;
                // 设置倒计时
                var interval_post_event = setInterval(function () {
                    if (PostLimitTime > 0) {
                        timeDown.textContent = "剩余:" + PostLimitTime + "秒";
                        PostLimitTime--;
                    } else {
                        clearInterval(interval_post_event); // 停止倒计时
                        timeDown.textContent = "允许回帖";
                    }
                }, 1000); // 每秒更新一次
            }
        }
    }
}

addTimeLabel();

setInterval(injectReplySubmit, 1000)