diff --git a/lib/form_filler.mjs b/lib/form_filler.mjs index d2b67bf..f13417b 100644 --- a/lib/form_filler.mjs +++ b/lib/form_filler.mjs @@ -96,7 +96,7 @@ export class FormFiller { // Work auth if (l.includes('sponsor') || l.includes('visa')) return p.work_authorization?.requires_sponsorship ? 'Yes' : 'No'; if (l.includes('relocat')) return p.willing_to_relocate ? 'Yes' : 'No'; - if (l.includes('authorized') || l.includes('eligible') || l.includes('legally') || l.includes('work in the u')) { + if (l.includes('authorized') || l.includes('eligible') || l.includes('legally') || l.includes('work in the u') || l.includes('right to work')) { return p.work_authorization?.authorized ? 'Yes' : 'No'; } if (l.includes('remote') && (l.includes('willing') || l.includes('comfortable') || l.includes('able to'))) return 'Yes'; @@ -493,7 +493,17 @@ Answer:`; const existing = await sel.inputValue().catch(() => ''); // "Select an option" is LinkedIn's placeholder — treat as unfilled if (existing && !/^select an? /i.test(existing)) continue; + // Get available options for validation + const availOpts = await sel.$$eval('option', els => + els.map(el => el.textContent?.trim()).filter(t => t && !/^select/i.test(t)) + ).catch(() => []); let answer = this.answerFor(lbl); + // If built-in answer doesn't match any option (e.g. got "7" but options are Yes/No), discard it + if (answer && availOpts.length > 0) { + const ansLower = answer.toLowerCase(); + const matches = availOpts.some(o => o.toLowerCase() === ansLower || o.toLowerCase().includes(ansLower) || ansLower.includes(o.toLowerCase())); + if (!matches) answer = null; + } if (!answer) { // EEO/voluntary fields — default to "Prefer not to disclose" const ll = lbl.toLowerCase();