Greasy Fork

Greasy Fork is available in English.

妖火按钮替换

其他人用户操作的管理按钮替换成感谢,对资源帖发送感谢分享

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         妖火按钮替换
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  其他人用户操作的管理按钮替换成感谢,对资源帖发送感谢分享
// @author       yh翼城
// @match       *://yaohuo.me/bbs-*
// @match       *://www.yaohuo.me/bbs-*
// @license      MIT
// @grant        none
// ==/UserScript==


(function() {
    window.reply = function (txt) {
        //复用复读机函数,调用后直接填写内容
        let domTextarea = document.querySelector("textarea");
        domTextarea.value = txt;
        //点击回复按钮
        let domInput = document.querySelectorAll("input");
        for (let iii = domInput.length - 1; iii > 0; iii--) {
            if (domInput[iii].value == "快速回复") {
                domInput[iii].click();
            }
            if (domInput[iii].value == "发表回复") {
                domInput[iii].click();
            }
        }
    }
    // 替换文本并设置点击事件
    function replaceTextAndSend() {
        const thankYouMessages = ["感谢分享.", "谢谢分享.", "感谢分享", "谢谢分享", "感谢分享!", "谢谢分享!"];

        const louzhuxinxiDiv = document.querySelector('.louzhuxinxi.subtitle');
        if (louzhuxinxiDiv) {
            const managementButtons = louzhuxinxiDiv.querySelectorAll('a[href*="Book_View_admin"]');
            managementButtons.forEach(button => {
                button.href = "javascript:;";
                button.textContent = "感谢"; // 修改按钮文本
                button.onclick = function(event) {
                    event.preventDefault(); // 阻止默认行为
                    // 随机选个
                    const randomIndex = Math.floor(Math.random() * thankYouMessages.length);
                    const message = thankYouMessages[randomIndex];
                    window.reply(message);
                };
            });
        }
    }

    // 初始化
    function init() {
        // 获取隐藏字段的值
        const touserid = document.querySelector('input[name="touserid"]').value;
        const myuserid = document.querySelector('input[name="myuserid"]').value;

        // 只有当 touserid 和 myuserid 不同时才执行初始化
        if (touserid !== myuserid) {
            replaceTextAndSend();
        }
    }

    // 执行初始化
    init();
})();