const TWEET_CONTAINER_SELECTOR = 'div[data-testid="primaryColumn"]'; const REPLIES_CONTAINER_SELECTOR = 'div[data-testid="reply"]'; export function observeTweets(callback: (element: HTMLElement) => void): void { const tweetContainer = document.querySelector(TWEET_CONTAINER_SELECTOR); if (tweetContainer) { const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === "childList") { mutation.addedNodes.forEach((node) => { if (node instanceof HTMLElement) { const replyContainer = node.querySelector(REPLIES_CONTAINER_SELECTOR); if (replyContainer) { callback(replyContainer); } } }); } }); }); observer.observe(tweetContainer, { childList: true, subtree: true, }); } }