您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
提取页面中的链接并添加一个按钮来复制这些链接
// ==UserScript== // @name 36RAIN_复制链接按钮 // @namespace http://tampermonkey.net/ // @version 2024-12-02 // @description 提取页面中的链接并添加一个按钮来复制这些链接 // @author 冰红茶真好喝 // @match http://36rain.com/u.php?action=favor&uid=* // @icon https://www.google.com/s2/favicons?sz=64&domain=36rain.com // @license MIT // @grant GM_setClipboard // @grant GM_addStyle // ==/UserScript== (function () { "use strict"; // 获取并修改所有链接 function getModifiedLinks() { const links = []; let index = 2; let linkElement; // 查找页面中的每个链接,并修改链接地址 while ( (linkElement = document.querySelector( `#u-contentmain > form > table > tbody > tr:nth-child(${index}) > th > a` )) ) { const originalLink = linkElement.href; const modifiedLink = originalLink.replace( "http://36rain.com/read.php?tid=", "https://rain36-vip.japaneast.cloudapp.azure.com/forum.php?mod=viewthread&tid=" ); links.push(modifiedLink); index++; } return links; } // 创建复制链接按钮 function createCopyButton() { const copyButton = document.createElement("button"); copyButton.textContent = "复制新站链接"; // copyButton.className = "btn"; // 设置按钮样式 copyButton.style.cssText = ` padding: 10px 20px; cursor: pointer; background-color: #4CAF50; color: white; border: none; border-radius: 5px; margin-right: 10px; `; // 按钮点击事件:提取链接并复制到剪切板 copyButton.addEventListener("click", () => { const links = getModifiedLinks(); // 获取修改后的链接 if (links.length > 0) { GM_setClipboard(links.join("\n")); // 将链接拼接成一行,复制到剪切板 alert("链接已复制到剪切板!"); } else { alert("未找到任何链接!"); } }); return copyButton; } // 创建打开新站按钮 function createOpenNewSiteButton() { const openButton = document.createElement("button"); openButton.textContent = "打开新站"; // openButton.className = "btn"; // 设置按钮样式 openButton.style.cssText = ` padding: 10px 20px; cursor: pointer; background-color: #008CBA; color: white; border: none; border-radius: 5px; `; // 按钮点击事件:打开新站链接 openButton.addEventListener("click", () => { window.open("https://rain36-vip.japaneast.cloudapp.azure.com/", "_blank"); }); return openButton; } // 插入按钮到页面中 function insertButtons() { const btnContainer = document.querySelector( "#u-contentmain > form > center > div" ); if (btnContainer) { const copyButton = createCopyButton(); // 创建复制链接按钮 const openButton = createOpenNewSiteButton(); // 创建打开新站按钮 btnContainer.appendChild(copyButton); // 将复制按钮添加到页面 btnContainer.appendChild(openButton); // 将打开新站按钮添加到页面 } } // 等待页面加载完成后插入按钮 window.addEventListener("load", insertButtons); })();