Untitled
hide race duplicationsjavascript
22 days ago
1.4 kB
0
Indexable
Never
// Function to process a single .item element function processItem(item) { const profileElement = item.querySelector('.profile'); if (profileElement) { const profileText = profileElement.textContent.trim(); // Increment the count for this profile text in the object profileTextCount[profileText] = (profileTextCount[profileText] || 0) + 1; // Check if the count for this profile text is greater than 5 if (profileTextCount[profileText] > 5) { // Hide the parent .item element item.style.display = 'none'; } } } // Create an object to store the count of each profile text const profileTextCount = {}; // Iterate through existing .item elements document.querySelectorAll('#gamelist .item').forEach(item => { processItem(item); }); // Create a MutationObserver to watch for changes in #gamelist const observer = new MutationObserver(mutationsList => { mutationsList.forEach(mutation => { if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { // Iterate through newly added .item elements mutation.addedNodes.forEach(addedNode => { if (addedNode.nodeType === 1 && addedNode.classList.contains('item')) { processItem(addedNode); } }); } }); }); // Start observing #gamelist for changes const gamelist = document.getElementById('gamelist'); observer.observe(gamelist, { childList: true, subtree: true });