From 2f33ea890d30a25e2500f4ee0f6c22637b2865fc Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Sun, 3 May 2026 12:43:03 -0700 Subject: [PATCH] googlejobs: link to external apply URL instead of Google deep-link The htidocid-based Google Jobs deep-links require the job to be in the current search context (location, session) to open the detail panel. When clicked from Telegram in a different context, the link only opens the search list page without the specific job detail. Each card's share_el ancestor has external apply URLs (Indeed, Glassdoor, Monster, BeBee, AAO Career Center, etc.) pre-loaded in the DOM. These are direct, stable links to the source job posting that work regardless of session or location. Switch jobUrl to use the first external (non-google.com) apply URL within the card's share_el. Co-Authored-By: Claude Sonnet 4.6 --- gimme_job/adapters/googlejobs.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/gimme_job/adapters/googlejobs.py b/gimme_job/adapters/googlejobs.py index 0c4c564..d7a8aee 100644 --- a/gimme_job/adapters/googlejobs.py +++ b/gimme_job/adapters/googlejobs.py @@ -17,21 +17,28 @@ _EXTRACT_JS = """() => { const shareEl = card.closest('[data-share-url]'); const shareUrl = shareEl ? shareEl.getAttribute('data-share-url') : ''; - // Build a clean udm=8 deep-link that opens the job detail panel. - // The shareUrl has session-tied tokens (shmd, shmds, shem) that can expire; - // we strip them and use only the htidocid + the new SPA fragment format. - let jobUrl = ''; let htidocid = ''; if (shareUrl) { const docMatch = shareUrl.match(/htidocid=([^&]+)/); - const qMatch = shareUrl.match(/[?&]q=([^&#]+)/); - if (docMatch) { - htidocid = decodeURIComponent(docMatch[1]); - const q = qMatch ? qMatch[1] : 'orthodontist+job'; - jobUrl = 'https://www.google.com/search?q=' + q + '&udm=8' - + '#vhid=vt%3D20/docid%3D' + docMatch[1] - + '&vssid=jobs-detail-viewer'; - } + if (docMatch) htidocid = decodeURIComponent(docMatch[1]); + } + + // Use the first external apply URL (Indeed, Glassdoor, Monster, etc.) + // pre-loaded inside the card's share_el. These are direct links to the + // source posting and work regardless of session/location, unlike + // Google Jobs htidocid deep-links which require the job to be in the + // current search context. + let jobUrl = ''; + if (shareEl) { + const links = Array.from(shareEl.querySelectorAll('a[href^="https://"]')); + const apply = links.find(a => { + const href = a.getAttribute('href') || ''; + return !href.includes('://www.google.com') + && !href.includes('://google.com') + && !href.includes('gstatic.com') + && !href.includes('accounts.google.com'); + }); + if (apply) jobUrl = apply.getAttribute('href'); } const dateSpan = card.querySelector('span[aria-label^="Posted"]');