2048自动回贴刷新

自动回帖后刷新

当前为 2024-08-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         2048自动回贴刷新
// @namespace    http://tampermonkey.net/
// @version      0.10
// @description  自动回帖后刷新
// @author       zzx114
// @match        https://hjd2048.com/2048/read.php?tid=*
// @grant        none
// @license MIT
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 在这里编写您的自动回复逻辑
    const replyMessage = "感谢楼主分享。";

    // 检测页面上是否已存在回复内容
    const existingReplies = document.querySelectorAll("#main > div:nth-child(18)"); // 更新为实际的回复内容选择器
    let isReplyPresent = false;
    existingReplies.forEach((reply) => {
        if (reply.textContent.includes(replyMessage)) {
            isReplyPresent = true;
        }
    });

    // 如果页面上没有预设的回复内容,则填充并提交回复
    if (!isReplyPresent) {
        setTimeout(() => {
         // const replyButton = document.querySelector("#reply-button"); // 替换为实际的回复按钮选择器
         // if (replyButton) {
        //      replyButton.click();
       //   }

            const replyInput = document.querySelector("textarea#textarea"); // 替换为实际的回复输入框选择器
            if (replyInput) {
                replyInput.value = replyMessage;
            }

            const submitButton = document.querySelector("input.btn"); // 替换为实际的提交按钮选择器
            if (submitButton) {
                submitButton.click();
            }
        }, 5000); // 等待5秒后再回复
    }

    // 如果页面上没有预设的回复内容,则在15秒后刷新页面
    if (!isReplyPresent) {
        setTimeout(() => {
            window.location.reload();
        }, 8000); // 等待5秒后回复,然后3秒后刷新页面
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址