diff options
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()); +}); |