From f168193e64793621652a86a3b2f238fe153f5b65 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 20 Jan 2025 10:39:07 -0400 Subject: userstuff: initial commit Userscripts and userstyles. Extension/platform-agnostic. At the moment we're using the macOS 'Userscripts' app (from the app store), which we've configured to point to a folder in iCloud Documents, 'Userscripts Folder'. 'Userscripts Folder' is flat and each file is hardlinked with the appropriate placement in userstuff, though we haven't checked if the Userscripts app breaks hardlinks or not. --- userstuff/youtube/Copy YouTube chat messages.user.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 userstuff/youtube/Copy YouTube chat messages.user.js (limited to 'userstuff/youtube/Copy YouTube chat messages.user.js') diff --git a/userstuff/youtube/Copy YouTube chat messages.user.js b/userstuff/youtube/Copy YouTube chat messages.user.js new file mode 100644 index 0000000..9665e12 --- /dev/null +++ b/userstuff/youtube/Copy YouTube chat messages.user.js @@ -0,0 +1,18 @@ +// ==UserScript== +// @name Copy YouTube chat messages +// @description Copies the text of a message when you click it (no emotes, sorry) +// @match https://www.youtube.com/live_chat_replay* +// ==/UserScript== + +document.body.addEventListener('click', event => { + const mouseElem = document.elementFromPoint(event.clientX, event.clientY); + if (!mouseElem) return; + const rendererElem = mouseElem.closest('yt-live-chat-text-message-renderer'); + if (!rendererElem) return; + const messageElem = rendererElem.querySelector('#message'); + if (!messageElem) { + console.warn(`Couldn't find message in message renderer`); + return; + } + navigator.clipboard.writeText(messageElem.innerText.trim()); +}); -- cgit 1.3.0-6-gf8a5