Repository navigation
Expand file tree
/
Copy pathcontent.js
More file actions
43 lines (38 loc) · 1.52 KB
/
Copy pathcontent.js
File metadata and controls
43 lines (38 loc) · 1.52 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
// content.js - Injected into all pages to extract job posting content.
// Messaged by the extension (shared.js extractTabContent) or falls back via scripting API.
function extractPageContent() {
// Priority-ordered selectors — covers LinkedIn, Indeed, Greenhouse, Lever, Workday, etc.
const selectors = [
'#job-description',
'.job-description',
'.job-description--wrapper',
'#jobDescriptionText', // Indeed
'.show-more-less-html__snippet', // LinkedIn (expanded)
'#content', // Greenhouse
'.posting-page', // Lever
'[data-automation="jobAdDetails"]',// Seek
'.jobsearch-JobComponent', // Indeed (alternate)
'main',
'article',
];
let content = '';
for (const selector of selectors) {
const el = document.querySelector(selector);
if (el && el.innerText.length > 200) {
content = el.innerText;
break;
}
}
// Fallback to full body if no targeted section found
if (content.length < 200) {
content = document.body.innerText;
}
// Normalise whitespace and cap at 15K chars (~3,750 tokens).
// Further per-provider truncation happens in ai_service.js.
return content.replace(/\s+/g, ' ').trim().slice(0, 15000);
}
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'extractJobContent') {
sendResponse({ text: extractPageContent() });
}
});