From 4fb5917c87d5c3869139ac79a77917f66c69e5db Mon Sep 17 00:00:00 2001 From: Claw Date: Fri, 6 Mar 2026 01:05:35 +0000 Subject: [PATCH] fix: restore real Wellfound apply logic in lib/apply/wellfound.mjs (not a stub) --- lib/apply/wellfound.mjs | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/apply/wellfound.mjs b/lib/apply/wellfound.mjs index 8e62f77..c978f4a 100644 --- a/lib/apply/wellfound.mjs +++ b/lib/apply/wellfound.mjs @@ -1,10 +1,37 @@ /** - * wellfound.mjs — Wellfound ATS handler - * TODO: implement + * wellfound.mjs — Wellfound apply handler */ -export const SUPPORTED_TYPES = ['wellfound']; +import { + NAVIGATION_TIMEOUT, PAGE_LOAD_WAIT, FORM_FILL_WAIT, SUBMIT_WAIT +} from '../constants.mjs'; + +export const SUPPORTED_TYPES = ['wellfound', 'wellfound_apply']; export async function apply(page, job, formFiller) { - return { status: 'skipped_external_unsupported', meta: { title: job.title, company: job.company }, - externalUrl: job.apply_url, ats_platform: 'wellfound' }; + await page.goto(job.url, { waitUntil: 'domcontentloaded', timeout: NAVIGATION_TIMEOUT }); + await page.waitForTimeout(PAGE_LOAD_WAIT); + + const meta = await page.evaluate(() => ({ + title: document.querySelector('h1')?.textContent?.trim(), + company: document.querySelector('[class*="company"] h2, [class*="startup"] h2, h2')?.textContent?.trim(), + })); + + const applyBtn = await page.$('a:has-text("Apply"), button:has-text("Apply Now"), a:has-text("Apply Now")'); + if (!applyBtn) return { status: 'no_button', meta }; + + await applyBtn.click(); + await page.waitForTimeout(FORM_FILL_WAIT); + + const unknowns = await formFiller.fill(page, formFiller.profile.resume_path); + + if (unknowns[0]?.honeypot) return { status: 'skipped_honeypot', meta }; + if (unknowns.length > 0) return { status: 'needs_answer', pending_question: unknowns[0], meta }; + + const submitBtn = await page.$('button[type="submit"]:not([disabled]), input[type="submit"]'); + if (!submitBtn) return { status: 'no_submit', meta }; + + await submitBtn.click(); + await page.waitForTimeout(SUBMIT_WAIT); + + return { status: 'submitted', meta }; }