// ==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 // @downloadURL 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(); })();