您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fixes broken Discord channel/thread/message copy ID buttons in Firefox.
当前为
// ==UserScript== // @name Discord Copy ID Fix (Firefox) // @description Fixes broken Discord channel/thread/message copy ID buttons in Firefox. // @author You // @version 0.1 // @namespace https://greasyfork.org/users/1376767 // @match https://discord.com/* // @grant GM_setClipboard // ==/UserScript== (function() { 'use strict'; function copyToClipboard(text) { GM_setClipboard(text); } function overrideClick(node) { const id = node.id; const match = id.match(/(\d+)$/); // id="channel-context-devmode-copy-id-123456" if (match) { const channelId = match[1]; node.addEventListener('click', function(event) { copyToClipboard(channelId); }, { once: true }); } } // right click creates a menu "class clickTrapContainer_ trapClicks_" // that has some child [role="menuitem"] // whose child has text "Copy ... ID" const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType === Node.ELEMENT_NODE) { // console.log(node); if (node.className && /clickTrapContainer_.*trapClicks_/.test(node.className)) { node.querySelectorAll('[role="menuitem"]').forEach(menuItem => { if (Array.from(menuItem.children).some(child => child.textContent?.startsWith("Copy") && child.textContent?.endsWith("ID"))) { setTimeout(() => overrideClick(menuItem), 100); } }); } } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })();