diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-20 10:39:07 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-20 10:43:43 -0400 |
commit | f168193e64793621652a86a3b2f238fe153f5b65 (patch) | |
tree | 70e2fd53eb269a1a8caab6a875d0271d74a4cf12 /userstuff/youtube/Copy YouTube chat messages.user.js | |
parent | 07f1dd42bcecd27b2bd6c7a6cfaa01f4fb40293b (diff) |
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.
Diffstat (limited to 'userstuff/youtube/Copy YouTube chat messages.user.js')
-rw-r--r-- | userstuff/youtube/Copy YouTube chat messages.user.js | 18 |
1 files changed, 18 insertions, 0 deletions
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()); +}); |