Greasy Fork

Greasy Fork is available in English.

按钮替换

把其他用户页面的管理操作替换成感谢,直接发送感谢分享

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         按钮替换
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  把其他用户页面的管理操作替换成感谢,直接发送感谢分享
// @author       yh翼城
// @match       *://yaohuo.me/bbs*
// @match       *://www.yaohuo.me/bbs*
// @license      MIT
// @grant        none
// ==/UserScript==


(function() {

    // 替换文本并设置点击事件
    function replaceTextAndSend() {
        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(); // 阻止默认行为
                    // 构造发送感谢消息的请求
                    window.reply("感谢分享");
                };
            });
        }
    }

    // 初始化
    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();
})();