From 43c5f8d0a7b9a364aca983e072c7013410c34d3e Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Fri, 5 Jun 2026 23:12:11 +0300 Subject: [PATCH] Auto-deploy: 2026-06-05 23:12:11 --- search_analyzer.js | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/search_analyzer.js b/search_analyzer.js index fb8bd45..e8ab423 100644 --- a/search_analyzer.js +++ b/search_analyzer.js @@ -96,44 +96,31 @@ // Find the main Action Button (Connect/Message/Follow) which every profile card has let allButtons = Array.from(document.querySelectorAll('button, a')); - console.log('[LJA] Total buttons/links on page:', allButtons.length); let actionElements = allButtons.filter(el => { if (!el.innerText) return false; let txt = el.innerText.toLowerCase().trim(); - // Must contain the word, but not be a huge paragraph if (txt.length === 0 || txt.length > 20) return false; - return txt.includes('connect') || txt.includes('message') || txt.includes('pending') || txt.includes('follow'); + // Exact match ONLY: avoid "8K followers" matching "follow" + return txt === 'connect' || txt === 'message' || txt === 'pending' || txt === 'follow' || txt === '+ connect'; }); - console.log('[LJA] Action buttons found (Connect/Message/etc):', actionElements.length, actionElements.map(e => e.innerText.trim())); + console.log('[LJA] Exact action buttons found:', actionElements.length, actionElements.map(e => e.innerText.trim())); actionElements.forEach(btn => { + // Go up and find the FIRST/SMALLEST ancestor with enough text to be a profile card let container = btn.parentElement; - // Go up the DOM tree (max 15 levels) to find the list item wrapper - let found = false; - for(let i=0; i<15; i++) { - if (!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); - found = true; - break; - } - } - // Fallback for non-LI structures - if (container.classList && (container.classList.contains('reusable-search__result-container') || container.classList.contains('search-entity'))) { + for(let i=0; i<25; i++) { + if (!container || container === document.body) break; + const txt = container.innerText; + // A profile card has at least 100 chars (name + headline + location + button) + // and not too many (< 3000 so we don't grab the whole results list) + if (txt && txt.length > 100 && txt.length < 3000) { uniqueCards.add(container); - found = true; break; } container = container.parentElement; } - if (!found) { - console.log('[LJA] Button found but could not find card container for:', btn.innerText.trim()); - } }); const cards = Array.from(uniqueCards);