JSFiddle - React, Tailwind, and code Playground
by deeeeekun
JavaScript
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
const observer = new MutationObserver((mutations) => {
Array.from(mutations).find(m => {
const found = Array.from(m.addedNodes)
.filter(n => n instanceof Element)
.find(n => {
const msg = n.querySelector('yt-live-chat-text-message-renderer #message');
if (msg) console.log(msg.innerText);
});
return found != undefined;
});
});
const point = document.querySelector('#chat-messages #item-list #item-scroller');
if (point) {
observer.observe(point, { childList: true, subtree: true });
}