Update
This commit is contained in:
1 parent
00934fecbb
commit
e90213d1ff
1 file changed
+15
-2
+15
-2
@@ -62,21 +62,34 @@ export class BrowserClient {
|
|||||||
try {
|
try {
|
||||||
const page = await this.getPage();
|
const page = await this.getPage();
|
||||||
await page.goto('https://www.reddit.com', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
await page.goto('https://www.reddit.com', { waitUntil: 'domcontentloaded', timeout: 30000 });
|
||||||
|
await page.waitForTimeout(2000);
|
||||||
|
|
||||||
const loginIndicators = [
|
const visibleIndicators = [
|
||||||
'[data-testid="user-drawer-button"]',
|
'[data-testid="user-drawer-button"]',
|
||||||
'button[aria-label*="User menu"]',
|
'button[aria-label*="User menu"]',
|
||||||
'a[href^="https://www.reddit.com/user/"]',
|
'a[href^="https://www.reddit.com/user/"]',
|
||||||
'a[href^="/user/"]',
|
'a[href^="/user/"]',
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const selector of loginIndicators) {
|
for (const selector of visibleIndicators) {
|
||||||
const el = page.locator(selector).first();
|
const el = page.locator(selector).first();
|
||||||
if (await el.isVisible().catch(() => false)) {
|
if (await el.isVisible().catch(() => false)) {
|
||||||
return true;
|
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.
|
// Fallback to a direct auth check; this avoids false negatives from hidden login buttons.
|
||||||
return await this.isLoggedInViaApi(page);
|
return await this.isLoggedInViaApi(page);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in new issue
Block a user