自动回贴刷新

自动回帖后刷新

目前為 2024-06-05 提交的版本,檢視 最新版本

// ==UserScript==
// @name         自动回贴刷新
// @namespace    http://tampermonkey.net/
// @version      0.11
// @description  自动回帖后刷新
// @author       zzx114
// @match        https://rjhome.me/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @require      https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js
// @require      https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 在这里编写您的自动回复逻辑
    const replyMessage = "非常好分享,谢谢。";

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

    // 如果页面上没有预设的回复内容,则填充并提交回复
    if (!isReplyPresent) {
        setTimeout(() => {
            const replyInput = document.querySelector(".com-form-textarea > #textarea"); // 替换为实际的回复输入框选择器
            if (replyInput) {
                replyInput.value = replyMessage;
            }

            const submitButton = document.querySelector("button.comments-mrxu-close:nth-child(2)"); // 替换为实际的提交按钮选择器
            if (submitButton) {
                submitButton.click();
            }
        }, 5000); // 等待5秒后再回复
    }

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