This commit is contained in:
jjbrunton committed 2026-01-05 15:15:16 +00:00
1 parent 00934fecbb
commit e90213d1ff
1 file changed
+15 -2
+15 -2
View File
@@ -62,21 +62,34 @@ export class BrowserClient {
try {
const page = await this.getPage();
await page.goto('https://www.reddit.com', { waitUntil: 'domcontentloaded', timeout: 30000 });
await page.waitForTimeout(2000);
const loginIndicators = [
const visibleIndicators = [
'[data-testid="user-drawer-button"]',
'button[aria-label*="User menu"]',
'a[href^="https://www.reddit.com/user/"]',
'a[href^="/user/"]',
];
for (const selector of loginIndicators) {
for (const selector of visibleIndicators) {
const el = page.locator(selector).first();
if (await el.isVisible().catch(() => false)) {
return true;
}
}
const attributeIndicators = [
'reddit-header-large[is-logged-in="true"]',
'shreddit-post-overflow-menu[current-user-id]',
];
for (const selector of attributeIndicators) {
const el = await page.$(selector);
if (el) {
return true;
}
}
// Fallback to a direct auth check; this avoids false negatives from hidden login buttons.
return await this.isLoggedInViaApi(page);
} catch (error) {