Update
This commit is contained in:
1 parent
cad1f7b842
commit
2a78f65b09
2 files changed
+69
-14
No files matched your search
+30
-10
@@ -238,20 +238,40 @@ export class RedditMessagePage {
|
||||
// Wait for page to stabilize
|
||||
await this.page.waitForTimeout(2000);
|
||||
|
||||
// Check for user menu button (indicates logged in)
|
||||
const userButton = await this.page.$('[data-testid="user-drawer-button"]');
|
||||
if (userButton) {
|
||||
const isVisible = await userButton.isVisible();
|
||||
return isVisible;
|
||||
const visibleIndicators = [
|
||||
'[data-testid="user-drawer-button"]',
|
||||
'button[aria-label*="User menu"]',
|
||||
];
|
||||
|
||||
for (const selector of visibleIndicators) {
|
||||
const el = this.page.locator(selector).first();
|
||||
if (await el.isVisible().catch(() => false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Alternative check - look for avatar or user icon
|
||||
const avatar = await this.page.$('[class*="avatar"], [class*="Avatar"]');
|
||||
if (avatar) {
|
||||
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 this.page.$(selector);
|
||||
if (el) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return await this.page.evaluate(async () => {
|
||||
try {
|
||||
const res = await fetch('https://www.reddit.com/api/me.json', { credentials: 'include' });
|
||||
if (!res.ok) return false;
|
||||
const data = await res.json();
|
||||
return Boolean(data && data.name);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('Failed to check login status:', error);
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user