From 2cf474899c9fc21d25616fc3d47e27ead1405305 Mon Sep 17 00:00:00 2001 From: Jamie Brunton Date: Mon, 5 Jan 2026 14:34:20 +0000 Subject: [PATCH] Update --- src/browser/client.ts | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/browser/client.ts b/src/browser/client.ts index c0a8624..ebcf3f8 100644 --- a/src/browser/client.ts +++ b/src/browser/client.ts @@ -96,6 +96,21 @@ export class BrowserClient { // Navigate to login page await page.goto('https://www.reddit.com/login', { waitUntil: 'domcontentloaded' }); + // Dismiss common consent dialogs if present + const consentSelectors = [ + 'button:has-text("Accept")', + 'button:has-text("I Accept")', + 'button:has-text("Allow all")', + 'button:has-text("OK")', + ]; + for (const selector of consentSelectors) { + const button = page.locator(selector).first(); + if (await button.isVisible().catch(() => false)) { + await button.click().catch(() => undefined); + break; + } + } + // Wait for inputs // Reddit uses various IDs but name="username" and name="password" are reliable this.logger.debug('Waiting for login form...'); @@ -110,8 +125,26 @@ export class BrowserClient { await page.fill('input[name="password"]', this.config.reddit.password); // Click login button - // Look for a button with type="submit" or text containing "Log In" - await page.click('button[type="submit"]'); // Standard form submit + // Look for a submit button or a "Log In" button + const submitSelectors = [ + 'button[type="submit"]', + 'button:has-text("Log In")', + 'button:has-text("Log in")', + '[role="button"]:has-text("Log In")', + '[role="button"]:has-text("Log in")', + ]; + let clicked = false; + for (const selector of submitSelectors) { + const button = page.locator(selector).first(); + if (await button.isVisible().catch(() => false)) { + await button.click(); + clicked = true; + break; + } + } + if (!clicked) { + throw new Error('Login failed: Could not find a visible submit button'); + } this.logger.info('Credentials submitted. Waiting for navigation...');