Auto-deploy: 2026-05-17 23:00:09
This commit is contained in:
45
content.js
45
content.js
@@ -230,16 +230,10 @@
|
|||||||
const questions = [];
|
const questions = [];
|
||||||
const seen = new Set();
|
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]
|
// LinkedIn wraps each form field in .fb-dash-form-element or [data-test-form-element]
|
||||||
const formElements = searchRoot.querySelectorAll(
|
// Search the whole document to avoid getting trapped in the wrong dialog (like the messaging pane).
|
||||||
'.fb-dash-form-element, [data-test-form-element]'
|
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 => {
|
formElements.forEach(el => {
|
||||||
@@ -268,25 +262,28 @@
|
|||||||
questions.push({ question: text, type: inputType });
|
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) {
|
if (questions.length === 0) {
|
||||||
const allLabels = searchRoot.querySelectorAll('label');
|
const activeModals = document.querySelectorAll('.jobs-easy-apply-modal, .artdeco-modal, [role="dialog"]');
|
||||||
allLabels.forEach(label => {
|
activeModals.forEach(modal => {
|
||||||
const ariaSpan = label.querySelector('span[aria-hidden="true"]');
|
const allLabels = modal.querySelectorAll('label');
|
||||||
let text = (ariaSpan ? ariaSpan.textContent : label.textContent)
|
allLabels.forEach(label => {
|
||||||
.replace(/\*/g, '').replace(/\n/g, ' ').replace(/\s+/g, ' ').trim();
|
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;
|
if (!text || text.length < 8 || text.length > 300 || seen.has(text.toLowerCase())) return;
|
||||||
|
|
||||||
const looksLikeQuestion = (
|
const looksLikeQuestion = (
|
||||||
text.endsWith('?') ||
|
text.endsWith('?') ||
|
||||||
/^(how many|what|do you|are you|have you|will you|describe|tell us)/i.test(text) ||
|
/^(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)
|
/salary|experience|education|degree|visa|relocat|notice|certif/i.test(text)
|
||||||
);
|
);
|
||||||
if (!looksLikeQuestion) return;
|
if (!looksLikeQuestion) return;
|
||||||
|
|
||||||
seen.add(text.toLowerCase());
|
seen.add(text.toLowerCase());
|
||||||
questions.push({ question: text, type: 'text' });
|
questions.push({ question: text, type: 'text' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user