Repository navigation
Expand file tree
/
Copy pathpatch_content.js
More file actions
61 lines (55 loc) · 2.29 KB
/
Copy pathpatch_content.js
File metadata and controls
61 lines (55 loc) · 2.29 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
const fs = require('fs');
const path = './extension/content.js';
let content = fs.readFileSync(path, 'utf8');
// 1. Update Title Selectors
content = content.replace(
/title: \(\) => firstMatch\(\[\s*'\.job-details[^\]]+\]/m,
`title: () => firstMatch([
'h1 a',
'.job-details-jobs-unified-top-card__job-title h1',
'.job-details-jobs-unified-top-card__job-title h2',
'.job-details-jobs-unified-top-card__job-title-link',
'.jobs-unified-top-card__job-title h1',
'.jobs-unified-top-card__job-title h2',
'.jobs-unified-top-card__job-title a',
'[class*="job-title"] h1',
'[class*="job-title"] h2',
'[class*="job-title"] a',
'h1[class*="job-title"]',
'h2[class*="job-title"]',
'h1.top-card-layout__title',
'h2.top-card-layout__title',
'.top-card-layout__title',
'h1'
]`
);
// 2. Update Location logic
content = content.replace(
/const split = text.split\('·'\);\n\s*if \(split\.length >= 2\) {\n\s*const loc = split\[1\]\.replace\(\/\\\(\(remote\|hybrid\|on-site\)\\\)\/gi, ''\)\.trim\(\);\n\s*if \(loc && !\/\\d\/\.test\(loc\)\) return loc;\n\s*}/m,
`const split = text.split('·');
if (split.length >= 1) {
// Check split[0] first (new layout: Location · Date)
let loc = split[0].replace(/\\((remote|hybrid|on-site)\\)/gi, '').trim();
if (loc && !/\\d/.test(loc) && !/reposted|promoted/i.test(loc)) return loc;
if (split.length >= 2) {
// Fallback to split[1] (old layout: Company · Location · Date)
loc = split[1].replace(/\\((remote|hybrid|on-site)\\)/gi, '').trim();
if (loc && !/\\d/.test(loc) && !/reposted|promoted/i.test(loc)) return loc;
}
}`
);
// 3. Update Date Posted logic
content = content.replace(
/\/\/ Strategy 2: scan top card for "X days ago" text/m,
`// Strategy 1.5: scan primary description directly for date
const primaryDesc = root.querySelector('[class*="primary-description"]');
if (primaryDesc) {
const parts = (primaryDesc.innerText || '').split('·').map(p => p.trim());
for (const part of parts) {
if (/ago|just now/i.test(part)) return part;
}
}
// Strategy 2: scan top card for "X days ago" text`
);
fs.writeFileSync(path, content, 'utf8');
console.log("Patched content.js");