From 97fac48bfd41d5b9939abe3da77b31523fcfe072 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 5 Jun 2026 23:08:11 +0300 Subject: [PATCH] Auto-deploy: 2026-06-05 23:08:11 --- search_analyzer.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/search_analyzer.js b/search_analyzer.js index ca70ac0..059c033 100644 --- a/search_analyzer.js +++ b/search_analyzer.js @@ -94,25 +94,29 @@ function findCards() { let uniqueCards = new Set(); - // The most bulletproof way to find a profile card is to find the main Action Button (Connect/Message/Follow) - // and then go up the DOM tree until we find the container that holds the whole profile - let actionElements = Array.from(document.querySelectorAll('button, a.artdeco-button')).filter(el => { + // Find the main Action Button (Connect/Message/Follow) which every profile card has + let actionElements = Array.from(document.querySelectorAll('button, a')).filter(el => { + if (!el.innerText) return false; let txt = el.innerText.toLowerCase().trim(); // Must contain the word, but not be a huge paragraph - return txt.length < 30 && (txt.includes('connect') || txt.includes('message') || txt.includes('pending') || txt.includes('follow')); + if (txt.length === 0 || txt.length > 20) return false; + return txt.includes('connect') || txt.includes('message') || txt.includes('pending') || txt.includes('follow'); }); actionElements.forEach(btn => { let container = btn.parentElement; - // Go up the DOM tree (max 15 levels) to find the list item + // Go up the DOM tree (max 15 levels) to find the list item wrapper for(let i=0; i<15; i++) { if (!container) break; - // A valid card container is usually an LI and contains an image and a profile link - if (container.tagName === 'LI' && container.querySelector('img') && container.querySelector('a[href*="/in/"]')) { - uniqueCards.add(container); - break; + // A valid card container is usually an LI + if (container.tagName === 'LI') { + // Ensure it has some text (a profile has name, headline, etc) + if (container.innerText && container.innerText.length > 30) { + uniqueCards.add(container); + break; + } } - // Fallback if it's not an LI but a direct container div used by some LinkedIn versions + // Fallback for non-LI structures if (container.classList && (container.classList.contains('reusable-search__result-container') || container.classList.contains('search-entity'))) { uniqueCards.add(container); break;