Auto-deploy: 2026-06-05 22:36:24
This commit is contained in:
@@ -278,15 +278,64 @@
|
||||
function processPage() {
|
||||
if (!window.location.href.includes('linkedin.com/search/results/')) return;
|
||||
|
||||
// Robustly find any <li> that contains a link to a LinkedIn profile
|
||||
const allLis = Array.from(document.querySelectorAll('li'));
|
||||
const cards = allLis.filter(li => li.querySelector('a[href*="/in/"]'));
|
||||
console.log('[LJA] Attempting to find profile cards...');
|
||||
let cards = [];
|
||||
|
||||
console.log('[LJA] processPage found cards:', cards.length);
|
||||
// Method 1: Try common structural wrappers for search results
|
||||
let listItems = Array.from(document.querySelectorAll('ul > li'));
|
||||
let validListItems = listItems.filter(li => li.innerText.length > 20 && li.querySelector('img'));
|
||||
if (validListItems.length > 0) {
|
||||
cards = validListItems;
|
||||
console.log('[LJA] Found cards via ul > li with images:', cards.length);
|
||||
}
|
||||
|
||||
// Method 2: Try finding elements containing headlines
|
||||
if (cards.length === 0) {
|
||||
let subtitles = document.querySelectorAll('.entity-result__primary-subtitle, [class*="subtitle"], .linked-area');
|
||||
let validSubtitles = Array.from(subtitles).filter(s => s.innerText.trim().length > 5);
|
||||
if (validSubtitles.length > 0) {
|
||||
let uniqueCards = new Set();
|
||||
validSubtitles.forEach(s => {
|
||||
let container = s.closest('li') || s.closest('div[data-chameleon-result-urn]') || s.parentElement.parentElement.parentElement;
|
||||
if (container) uniqueCards.add(container);
|
||||
});
|
||||
cards = Array.from(uniqueCards);
|
||||
console.log('[LJA] Found cards via subtitles:', cards.length);
|
||||
}
|
||||
}
|
||||
|
||||
// Method 3: Deep heuristic using profile links
|
||||
if (cards.length === 0) {
|
||||
let profileLinks = Array.from(document.querySelectorAll('a[href*="/in/"]')).filter(a => a.innerText.trim().length > 3 && !a.querySelector('img'));
|
||||
console.log('[LJA] Profile links found:', profileLinks.length);
|
||||
|
||||
let uniqueCards = new Set();
|
||||
profileLinks.forEach(link => {
|
||||
let container = link.parentElement;
|
||||
let bestContainer = null;
|
||||
// Go up to 8 levels looking for a substantial block
|
||||
for(let i = 0; i < 8; i++) {
|
||||
if (!container) break;
|
||||
// A good card container has significant text and usually buttons
|
||||
if (container.innerText.length > 50 && container.querySelectorAll('button').length > 0) {
|
||||
bestContainer = container;
|
||||
}
|
||||
container = container.parentElement;
|
||||
}
|
||||
if (bestContainer) uniqueCards.add(bestContainer);
|
||||
});
|
||||
cards = Array.from(uniqueCards);
|
||||
console.log('[LJA] Found cards via link heuristics:', cards.length);
|
||||
}
|
||||
|
||||
// Deduplicate cards just in case
|
||||
cards = Array.from(new Set(cards));
|
||||
|
||||
if (cards.length > 0) {
|
||||
injectScanAllButton();
|
||||
cards.forEach(injectScanButton);
|
||||
} else {
|
||||
console.log('[LJA] No cards could be identified on this page.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user