-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-selectors.js
More file actions
executable file
·156 lines (140 loc) · 5.58 KB
/
test-selectors.js
File metadata and controls
executable file
·156 lines (140 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// JobSieve Selector Test Script
// Run this in the browser console on a LinkedIn jobs page to test selectors
console.log('🔍 JobSieve Selector Test Starting...');
// Selector configuration (matches content.js)
const selectorConfig = {
jobCards: {
primary: '[data-job-id]',
fallbacks: [
'[data-occludable-job-id]',
'.job-card-container',
'.jobs-search-results__list-item',
'.job-card-list',
'.ember-view[data-occludable-job-id]',
'.scaffold-layout__list-item'
]
},
company: {
primary: '.artdeco-entity-lockup__subtitle .AEuhFmZyMboxPGoVPjFnHnVGyLtrNdAjWVppI',
fallbacks: [
'.artdeco-entity-lockup__subtitle span[dir="ltr"]',
'.artdeco-entity-lockup__subtitle span',
'.artdeco-entity-lockup__subtitle',
'.job-card-container__company-name',
'[data-entity-urn*="company"]',
'.job-card-search__company-name',
'[aria-label*="company" i]'
]
},
location: {
primary: '.artdeco-entity-lockup__caption .DJmjhrULCEeVHdRIuxazWNSsFOOdWKIsE',
fallbacks: [
'.job-card-container__metadata-wrapper li span[dir="ltr"]',
'.artdeco-entity-lockup__caption li span[dir="ltr"]',
'.artdeco-entity-lockup__caption li span',
'.job-card-container__metadata-wrapper li',
'.job-card-container__location',
'.job-card-search__location',
'[aria-label*="location" i]',
'.artdeco-entity-lockup__subtitle'
]
},
title: {
primary: '.artdeco-entity-lockup__title a',
fallbacks: [
'.job-card-list__title--link',
'.job-card-container__link',
'.job-card-container__title',
'.job-card-search__title',
'a[aria-label]',
'h3[aria-label]',
'.artdeco-entity-lockup__title'
]
},
promoted: {
primary: '.job-card-container__footer-item--promoted',
fallbacks: [
'.job-card-container__footer-item',
'.job-card-list__footer-wrapper .job-card-container__footer-job-state',
'.artdeco-entity-lockup__badge',
'.job-card-container__footer-wrapper'
]
}
};
// Helper function to test selectors
function findElement(container, selectorType) {
const selectors = selectorConfig[selectorType];
if (!selectors) return null;
// Try primary selector first
let element = container.querySelector(selectors.primary);
if (element) return { element, selectorUsed: selectors.primary, isPrimary: true };
// Try fallback selectors
for (const fallback of selectors.fallbacks) {
element = container.querySelector(fallback);
if (element) {
return { element, selectorUsed: fallback, isPrimary: false };
}
}
return null;
}
// Get job cards
const jobCardsResult = [];
let cards = Array.from(document.querySelectorAll(selectorConfig.jobCards.primary));
if (cards.length === 0) {
for (const fallback of selectorConfig.jobCards.fallbacks) {
cards = Array.from(document.querySelectorAll(fallback));
if (cards.length > 0) {
console.warn(`⚠️ Using fallback job card selector: ${fallback}`);
break;
}
}
}
console.log(`📋 Found ${cards.length} job cards`);
if (cards.length === 0) {
console.error('❌ No job cards found! Check if you\'re on a LinkedIn jobs page.');
} else {
// Test each selector type on the first few cards
const testCards = cards.slice(0, Math.min(3, cards.length));
testCards.forEach((card, index) => {
console.log(`\n🧪 Testing Card ${index + 1}:`);
// Test each selector type
Object.keys(selectorConfig).forEach(selectorType => {
if (selectorType === 'jobCards') return; // Skip, already tested
const result = findElement(card, selectorType);
if (result) {
const text = result.element.textContent?.trim().substring(0, 50) + '...';
const status = result.isPrimary ? '✅' : '⚠️';
console.log(` ${status} ${selectorType}: "${text}" (${result.selectorUsed})`);
} else {
console.log(` ❌ ${selectorType}: Not found`);
}
});
});
// Summary
console.log(`\n📊 Summary:`);
console.log(`Total job cards found: ${cards.length}`);
// Test promoted detection
let promotedCount = 0;
let viewedCount = 0;
cards.forEach(card => {
// Check promoted
const promotedResult = findElement(card, 'promoted');
if (promotedResult && /promoted/i.test(promotedResult.element.textContent)) {
promotedCount++;
} else {
const footerEls = card.querySelectorAll('.job-card-container__footer-wrapper, .job-card-list__footer-wrapper');
for (const el of footerEls) {
if (/\bpromoted\b/i.test(el.textContent)) { promotedCount++; break; }
}
}
// Check viewed
const titleLink = findElement(card, 'title');
if (titleLink && titleLink.element) {
if (titleLink.element.classList.contains('job-card-list__title--is-visited')) viewedCount++;
}
});
console.log(`Promoted jobs detected: ${promotedCount}`);
console.log(`Viewed jobs detected: ${viewedCount}`);
}
console.log('\n✅ JobSieve Selector Test Complete!');
console.log('Copy and paste this script into the browser console on any LinkedIn jobs page (search, collections, or view) to test.');