From a7a782c4227d80935225776286e4d7789fa03721 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sun, 17 May 2026 23:00:09 +0300 Subject: [PATCH] Auto-deploy: 2026-05-17 23:00:09 --- content.js | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/content.js b/content.js index c2c0a91..3ab9d8d 100644 --- a/content.js +++ b/content.js @@ -230,16 +230,10 @@ const questions = []; const seen = new Set(); - // Find the Easy Apply modal using real LinkedIn selectors - const modal = document.querySelector( - '[role="dialog"].jobs-easy-apply-modal, .artdeco-modal.jobs-easy-apply-modal, ' + - '.artdeco-modal, [role="dialog"], #artdeco-modal-outlet' - ); - const searchRoot = modal || document.body; - // LinkedIn wraps each form field in .fb-dash-form-element or [data-test-form-element] - const formElements = searchRoot.querySelectorAll( - '.fb-dash-form-element, [data-test-form-element]' + // Search the whole document to avoid getting trapped in the wrong dialog (like the messaging pane). + const formElements = document.querySelectorAll( + '.jobs-easy-apply-modal .fb-dash-form-element, .jobs-easy-apply-modal [data-test-form-element], .fb-dash-form-element, [data-test-form-element]' ); formElements.forEach(el => { @@ -268,25 +262,28 @@ questions.push({ question: text, type: inputType }); }); - // Fallback: if the precise approach found nothing, scan broader + // Fallback: if the precise approach found nothing, scan broader inside modals if (questions.length === 0) { - const allLabels = searchRoot.querySelectorAll('label'); - allLabels.forEach(label => { - const ariaSpan = label.querySelector('span[aria-hidden="true"]'); - let text = (ariaSpan ? ariaSpan.textContent : label.textContent) - .replace(/\*/g, '').replace(/\n/g, ' ').replace(/\s+/g, ' ').trim(); - - if (!text || text.length < 8 || text.length > 300 || seen.has(text.toLowerCase())) return; - - const looksLikeQuestion = ( - text.endsWith('?') || - /^(how many|what|do you|are you|have you|will you|describe|tell us)/i.test(text) || - /salary|experience|education|degree|visa|relocat|notice|certif/i.test(text) - ); - if (!looksLikeQuestion) return; + const activeModals = document.querySelectorAll('.jobs-easy-apply-modal, .artdeco-modal, [role="dialog"]'); + activeModals.forEach(modal => { + const allLabels = modal.querySelectorAll('label'); + allLabels.forEach(label => { + const ariaSpan = label.querySelector('span[aria-hidden="true"]'); + let text = (ariaSpan ? ariaSpan.textContent : label.textContent) + .replace(/\*/g, '').replace(/\n/g, ' ').replace(/\s+/g, ' ').trim(); + + if (!text || text.length < 8 || text.length > 300 || seen.has(text.toLowerCase())) return; + + const looksLikeQuestion = ( + text.endsWith('?') || + /^(how many|what|do you|are you|have you|will you|describe|tell us)/i.test(text) || + /salary|experience|education|degree|visa|relocat|notice|certif/i.test(text) + ); + if (!looksLikeQuestion) return; - seen.add(text.toLowerCase()); - questions.push({ question: text, type: 'text' }); + seen.add(text.toLowerCase()); + questions.push({ question: text, type: 'text' }); + }); }); }