Auto-deploy: 2026-06-05 23:08:11
This commit is contained in:
@@ -94,25 +94,29 @@
|
|||||||
function findCards() {
|
function findCards() {
|
||||||
let uniqueCards = new Set();
|
let uniqueCards = new Set();
|
||||||
|
|
||||||
// The most bulletproof way to find a profile card is to find the main Action Button (Connect/Message/Follow)
|
// Find the main Action Button (Connect/Message/Follow) which every profile card has
|
||||||
// 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')).filter(el => {
|
||||||
let actionElements = Array.from(document.querySelectorAll('button, a.artdeco-button')).filter(el => {
|
if (!el.innerText) return false;
|
||||||
let txt = el.innerText.toLowerCase().trim();
|
let txt = el.innerText.toLowerCase().trim();
|
||||||
// Must contain the word, but not be a huge paragraph
|
// 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 => {
|
actionElements.forEach(btn => {
|
||||||
let container = btn.parentElement;
|
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++) {
|
for(let i=0; i<15; i++) {
|
||||||
if (!container) break;
|
if (!container) break;
|
||||||
// A valid card container is usually an LI and contains an image and a profile link
|
// A valid card container is usually an LI
|
||||||
if (container.tagName === 'LI' && container.querySelector('img') && container.querySelector('a[href*="/in/"]')) {
|
if (container.tagName === 'LI') {
|
||||||
uniqueCards.add(container);
|
// Ensure it has some text (a profile has name, headline, etc)
|
||||||
break;
|
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'))) {
|
if (container.classList && (container.classList.contains('reusable-search__result-container') || container.classList.contains('search-entity'))) {
|
||||||
uniqueCards.add(container);
|
uniqueCards.add(container);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user