79553845

Date: 2025-04-03 19:41:30
Score: 1
Natty:
Report link

maybe try a DOMContentLoaded event listener to begin?

document.addEventListener("DOMContentLoaded", (event) => {
  console.log("DOM fully loaded and parsed");
  setTimeout(startObserver, 2000);
});

function startObserver() {
        const observedArea = document.querySelector(".c_ChatRoom__list-item-counter");
        
        if (!observedArea) {
            console.log("⚠️ Observed area not found! Retrying in 1s...");
            setTimeout(startObserver, 1000);
            return;
        }

        const observer = new MutationObserver(() => {
            const highlightedElement = observedArea.querySelector(".c_ChatRoom__list-item-counter.is-highlighted");

            if (highlightedElement) {
                console.log("🔥 Spot available! Waiting 0.1s before clicking...");
                setTimeout(() => {
                    const counter = highlightedElement.closest(".c_ChatRoom__list-item").querySelector(".c_ChatRoom__list-item-counter");
                    if (counter) {
                        console.log("🖱️ Clicking on the available spot now!");
                        counter.click();
                    }
                    observer.disconnect();
                    console.log("🔌 Observer deactivated.");
                    
                    setTimeout(() => {
                        console.log("🔄 Reactivating observer...");
                        observer.observe(observedArea, { childList: true, subtree: true });
                    }, 5000);
                }, 100);
            }
        });

        observer.observe(observedArea, { childList: true, subtree: true });
        console.log("👀 Observing changes inside the chat rooms availability list...");
}
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: dbakr