Skip to content

Commit 0469a3b

Browse files
author
Sam Razavi
committed
Extension 1.0.2: Platsbanken company name, LinkedIn in-app navigation, tabs open before install
- Platsbanken: the company was never read. The page's element is #pb-company-name and there is no JSON-LD; it is now read from there, with the 'Title - Employer - Platsbanken' document title as a fallback. - LinkedIn is a single-page app: arriving at a job from the feed loads no new document, so a script limited to /jobs/* was never there to answer. The script now matches all of www.linkedin.com and only marks listings under /jobs. - The popup and the shortcut load the site script on demand into a tab that has none (one open before the extension was installed or updated), on the supported sites only. Needs the 'scripting' permission. - Site scripts guard against running twice.
1 parent ffa1ac6 commit 0469a3b

9 files changed

Lines changed: 146 additions & 15 deletions

File tree

‎CLAUDE.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ Browser Extension delivered in June 2026 (`applyluma-extension/`):
183183
Indeed search panes (`?vjk=`) count as job pages, with canonical
184184
`/jobs/view/<id>/` and `/viewjob?jk=` URLs. Intensity values are now
185185
light/medium/aggressive.
186+
- 1.0.2 (November 2026): Platsbanken company name was never read (the page's
187+
element is `#pb-company-name`, there is no JSON-LD; now also falls back to the
188+
"Title - Employer - Platsbanken" document title). LinkedIn's content script
189+
matches all of `www.linkedin.com` (it is a single-page app: arriving at a job
190+
from the feed loads no new document, so a `/jobs/*` script was never there).
191+
Popup and shortcut load the site script on demand (`scripting` permission,
192+
supported hosts only) into a tab that was open before install/update. Site
193+
scripts guard against running twice (`ApplyLuma.siteLoaded`).
186194
- Server-side compatibility for the released 1.0.0: the bookmark response
187195
also carries `raw_job_posting_id` (1.0.0 read that name and got
188196
undefined, so match score, "Track application" and AI Tailor silently did

‎applyluma-extension/background.js‎

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,62 @@ const JOB_SITE_PATTERNS = [
1616
'https://www.arbetsformedlingen.se/*',
1717
];
1818

19+
// Same helpers as popup/popup.js (the two run in separate contexts).
20+
// The page script that reads each supported site. Used to load it on demand
21+
// into a tab that has none: one that was open before the extension was
22+
// installed or updated.
23+
const SITE_SCRIPTS = [
24+
[/(^|\.)linkedin\.com$/, 'content/linkedin.js'],
25+
[/(^|\.)indeed\.com$/, 'content/indeed.js'],
26+
[/(^|\.)arbetsformedlingen\.se$/, 'content/platsbanken.js'],
27+
[/(^|\.)glassdoor\.com$/, 'content/glassdoor.js'],
28+
];
29+
30+
function siteScriptFor(url) {
31+
try {
32+
const host = new URL(url).hostname;
33+
const match = SITE_SCRIPTS.find(([pattern]) => pattern.test(host));
34+
return match ? match[1] : null;
35+
} catch {
36+
return null;
37+
}
38+
}
39+
40+
// Ask the tab's page script for the job. Resolves to null if nothing answers.
41+
async function askTab(tabId) {
42+
try {
43+
return await Promise.race([
44+
chrome.tabs.sendMessage(tabId, { type: 'EXTRACT_JOB' }),
45+
new Promise((resolve) => setTimeout(() => resolve(null), 1500)),
46+
]);
47+
} catch {
48+
return null; // no ApplyLuma script on this tab
49+
}
50+
}
51+
52+
// Ask the tab; if it has no page script yet and is a supported site, load the
53+
// script and ask again. tab.url is only visible for sites the extension has
54+
// permission for, so nothing is ever loaded into any other page.
55+
async function readJobFromTab(tab) {
56+
if (!tab || tab.id === undefined) return null;
57+
let reply = await askTab(tab.id);
58+
if (!reply) {
59+
const script = siteScriptFor(tab.url || '');
60+
if (script) {
61+
try {
62+
await chrome.scripting.executeScript({
63+
target: { tabId: tab.id },
64+
files: ['content/common.js', script],
65+
});
66+
reply = await askTab(tab.id);
67+
} catch {
68+
// The page refused the script (a browser page, or a frame still loading).
69+
}
70+
}
71+
}
72+
return reply;
73+
}
74+
1975
// ── Auth helpers ─────────────────────────────────────────────────────────────
2076

2177
async function getTokens() {
@@ -147,10 +203,8 @@ chrome.commands.onCommand.addListener(async (command) => {
147203
let answered = false;
148204
try {
149205
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
150-
if (tab && tab.id !== undefined) {
151-
const reply = await chrome.tabs.sendMessage(tab.id, { type: 'EXTRACT_JOB' });
152-
if (reply) { answered = true; job = reply.job || null; }
153-
}
206+
const reply = await readJobFromTab(tab);
207+
if (reply) { answered = true; job = reply.job || null; }
154208
} catch { /* no ApplyLuma script on this tab */ }
155209
if (!answered) {
156210
const { linkedinJob: rawJob } = await chrome.storage.local.get('linkedinJob');

‎applyluma-extension/content/glassdoor.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
(function () {
55
'use strict';
6+
if (ApplyLuma.siteLoaded) return;
7+
ApplyLuma.siteLoaded = true;
68

79
const TITLE_SELECTORS = [
810
'[data-test="job-title"]',

‎applyluma-extension/content/indeed.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
(function () {
55
'use strict';
6+
if (ApplyLuma.siteLoaded) return;
7+
ApplyLuma.siteLoaded = true;
68

79
const TITLE_SELECTORS = [
810
'[data-testid="jobsearch-JobInfoHeader-title"]',

‎applyluma-extension/content/linkedin.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
(function () {
55
'use strict';
6+
if (ApplyLuma.siteLoaded) return;
7+
ApplyLuma.siteLoaded = true;
68

79
// ── Selector sets — primary then fallbacks ──────────────────────────────
810

@@ -171,7 +173,9 @@
171173
setTimeout(extractJobData, 800);
172174
}
173175
// Re-inject badges as new cards load (infinite scroll / SPA pagination).
174-
void refreshBadges();
176+
// Only under /jobs: the script is present on all of LinkedIn so it can
177+
// answer after in-app navigation, but it has nothing to do on the feed.
178+
if (location.pathname.startsWith('/jobs')) void refreshBadges();
175179
}).observe(document, { subtree: true, childList: true });
176180

177181
// ── Message listener (from background worker) ────────────────────────────

‎applyluma-extension/content/platsbanken.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
(function () {
55
'use strict';
6+
if (ApplyLuma.siteLoaded) return;
7+
ApplyLuma.siteLoaded = true;
68

79
const TITLE_SELECTORS = [
810
'[class*="JobAd_title"]',
@@ -12,13 +14,15 @@
1214
];
1315

1416
const COMPANY_SELECTORS = [
17+
'#pb-company-name',
1518
'[class*="JobAd_employer"]',
1619
'[class*="employer-name"]',
1720
'[class*="company-name"]',
1821
'[data-testid="employer-name"]',
1922
];
2023

2124
const DESCRIPTION_SELECTORS = [
25+
'lib-pb-section-job-main-content',
2226
'[class*="JobAd_description"]',
2327
'[class*="job-description"]',
2428
'[class*="JobDescription"]',
@@ -47,6 +51,13 @@
4751
title: TITLE_SELECTORS,
4852
company: COMPANY_SELECTORS,
4953
description: DESCRIPTION_SELECTORS,
54+
// An ad's page is titled "Job title - Employer - Platsbanken". The title
55+
// itself may contain " - ", so the employer is the part before the suffix.
56+
fromDocumentTitle: () => {
57+
const parts = document.title.split(' - ');
58+
if (parts.length < 3 || parts[parts.length - 1].trim() !== 'Platsbanken') return null;
59+
return { title: parts.slice(0, -2).join(' - ').trim(), company: parts[parts.length - 2].trim() };
60+
},
5061
};
5162

5263
function extractJobData() {

‎applyluma-extension/manifest.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"manifest_version": 3,
33
"name": "ApplyLuma",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"description": "Save job postings from LinkedIn, Indeed, Glassdoor, and Arbetsförmedlingen to ApplyLuma with one click.",
66
"homepage_url": "https://applyluma.com",
7-
"permissions": ["storage", "alarms", "notifications"],
7+
"permissions": ["storage", "alarms", "notifications", "scripting"],
88
"content_security_policy": {
99
"extension_pages": "script-src 'self'; object-src 'self'"
1010
},
@@ -37,7 +37,7 @@
3737
],
3838
"content_scripts": [
3939
{
40-
"matches": ["https://www.linkedin.com/jobs/*"],
40+
"matches": ["https://www.linkedin.com/*"],
4141
"js": ["content/common.js", "content/linkedin.js"],
4242
"run_at": "document_idle"
4343
},

‎applyluma-extension/popup/popup.js‎

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,67 @@ const SAVED_JOBS_URL = 'https://applyluma.com/discover?tab=saved';
150150
// Ask the page in the active tab to read the job now. Reading on demand gets
151151
// fields that had not rendered yet when the page first loaded, and always
152152
// describes this tab rather than whichever tab was read last.
153-
async function extractFromActiveTab() {
153+
// The page script that reads each supported site. Used to load it on demand
154+
// into a tab that has none: one that was open before the extension was
155+
// installed or updated.
156+
const SITE_SCRIPTS = [
157+
[/(^|\.)linkedin\.com$/, 'content/linkedin.js'],
158+
[/(^|\.)indeed\.com$/, 'content/indeed.js'],
159+
[/(^|\.)arbetsformedlingen\.se$/, 'content/platsbanken.js'],
160+
[/(^|\.)glassdoor\.com$/, 'content/glassdoor.js'],
161+
];
162+
163+
function siteScriptFor(url) {
154164
try {
155-
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
156-
if (!tab || tab.id === undefined) return { answered: false };
157-
const reply = await Promise.race([
158-
chrome.tabs.sendMessage(tab.id, { type: 'EXTRACT_JOB' }),
165+
const host = new URL(url).hostname;
166+
const match = SITE_SCRIPTS.find(([pattern]) => pattern.test(host));
167+
return match ? match[1] : null;
168+
} catch {
169+
return null;
170+
}
171+
}
172+
173+
// Ask the tab's page script for the job. Resolves to null if nothing answers.
174+
async function askTab(tabId) {
175+
try {
176+
return await Promise.race([
177+
chrome.tabs.sendMessage(tabId, { type: 'EXTRACT_JOB' }),
159178
new Promise((resolve) => setTimeout(() => resolve(null), 1500)),
160179
]);
180+
} catch {
181+
return null; // no ApplyLuma script on this tab
182+
}
183+
}
184+
185+
// Ask the tab; if it has no page script yet and is a supported site, load the
186+
// script and ask again. tab.url is only visible for sites the extension has
187+
// permission for, so nothing is ever loaded into any other page.
188+
async function readJobFromTab(tab) {
189+
if (!tab || tab.id === undefined) return null;
190+
let reply = await askTab(tab.id);
191+
if (!reply) {
192+
const script = siteScriptFor(tab.url || '');
193+
if (script) {
194+
try {
195+
await chrome.scripting.executeScript({
196+
target: { tabId: tab.id },
197+
files: ['content/common.js', script],
198+
});
199+
reply = await askTab(tab.id);
200+
} catch {
201+
// The page refused the script (a browser page, or a frame still loading).
202+
}
203+
}
204+
}
205+
return reply;
206+
}
207+
208+
async function extractFromActiveTab() {
209+
try {
210+
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
211+
const reply = await readJobFromTab(tab);
161212
return reply ? { answered: true, job: reply.job || null } : { answered: false };
162213
} catch {
163-
// No ApplyLuma script on this tab (not a supported site, or a tab that
164-
// was open before the extension was installed).
165214
return { answered: false };
166215
}
167216
}

‎applyluma-extension/store/STORE_LISTING.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Save job postings the user is viewing on supported job boards to their ApplyLuma
5353
| `storage` | Stores the user's ApplyLuma sign-in token, the job details read from the current posting (kept 15 minutes) and the list of already-saved/applied job URLs used to badge listings. |
5454
| `alarms` | Refreshes the saved/applied job URL list from the ApplyLuma API every 30 minutes so badges stay current. |
5555
| `notifications` | Confirms success or failure when a job is saved with the keyboard shortcut, since no popup is open in that case. |
56+
| `scripting` | Loads the extension's own packaged page script into the active tab when the user opens the popup or uses the shortcut on one of the supported job sites and that tab has no script yet (a tab that was already open when the extension was installed or updated). It is only ever used on the host-permission sites below and only loads files from the package. |
5657
| Host: `www.linkedin.com`, `se.indeed.com`, `www.indeed.com`, `www.glassdoor.com`, `arbetsformedlingen.se`, `www.arbetsformedlingen.se` | Content scripts read the job title, company, URL and description from job posting pages on these sites, and mark listings the user already saved or applied to. No other sites are accessed. |
5758
| Host: `applyluma-production.up.railway.app` | The ApplyLuma API, where saved jobs are sent and the user's saved/applied list is read. |
5859
| Remote code | No. All JavaScript ships in the package; there is no `eval` and no remotely loaded script. |

0 commit comments

Comments
 (0)