blob: 9665e1293ce6fcb42e4c72c53c4c124ade24baae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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());
});
|