← back to Pattern Vault
capture-session: robust login detect (no-password-field + domain) + 10min + auto-raise window
6800cc2346233da172f0d7c794eda1ecbe661188 · 2026-07-09 19:10:09 -0700 · Steve
Files touched
M wpb-uploaders/capture-session.js
Diff
commit 6800cc2346233da172f0d7c794eda1ecbe661188
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Jul 9 19:10:09 2026 -0700
capture-session: robust login detect (no-password-field + domain) + 10min + auto-raise window
---
wpb-uploaders/capture-session.js | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/wpb-uploaders/capture-session.js b/wpb-uploaders/capture-session.js
index 4c1d8f9..5c98287 100644
--- a/wpb-uploaders/capture-session.js
+++ b/wpb-uploaders/capture-session.js
@@ -26,12 +26,16 @@ const LOGIN = { creativemarket: 'https://creativemarket.com/login', redbubble: '
society6: 'https://society6.com/login', patternbank: 'https://patternbank.com/login' }[platform];
const sleep = ms => new Promise(r => setTimeout(r, ms));
-// logged-in heuristic: off the login/auth URL AND a logged-in marker is present.
+// logged-in heuristic (robust): off the login/auth URL AND no password field visible.
+// A logged-out page still shows the login form (password input); once you're in, it's gone.
async function isLoggedIn(pg) {
const u = pg.url();
- if (/\/login|\/signin|\/auth\/login|\/sign_in/i.test(u)) return false;
- const marker = await pg.$('a[href*="logout" i], a[href*="sign_out" i], button:has-text("Log out"), button:has-text("Sign out"), a[href*="/account" i], [aria-label*="account" i], img[alt*="avatar" i], [class*="avatar" i]').catch(() => null);
- return !!marker;
+ if (/\/login|\/signin|\/auth\/login|\/sign_in|\/sessions\/new|accounts\.google\.com/i.test(u)) return false;
+ const pwField = await pg.$('input[type=password]').catch(() => null);
+ if (pwField) return false; // still on a login form somewhere
+ // extra confidence: an account/logout marker OR simply being on the platform's own domain
+ const marker = await pg.$('a[href*="logout" i], a[href*="sign_out" i], button:has-text("Log out"), button:has-text("Sign out"), a[href*="/account" i], a[href*="dashboard" i], [aria-label*="account" i], [class*="avatar" i]').catch(() => null);
+ return !!marker || /creativemarket\.com|redbubble\.com|society6\.com|patternbank\.com/i.test(u);
}
(async () => {
@@ -46,7 +50,11 @@ async function isLoggedIn(pg) {
const pg = await ctx.newPage();
await pg.goto(LOGIN, { waitUntil: 'domcontentloaded', timeout: 60000 }).catch(() => {});
- const deadline = Date.now() + 5 * 60 * 1000; // 5 min
+ // nudge the window to the front (Playwright's browser often opens behind others)
+ const { exec } = require('child_process');
+ exec(`osascript -e 'tell application "System Events" to set frontmost of (first process whose name contains "Chrome for Testing") to true' 2>/dev/null`);
+
+ const deadline = Date.now() + 10 * 60 * 1000; // 10 min
let stable = 0, saved = false;
while (Date.now() < deadline) {
await sleep(3000);
← bd366e3 capture-session: auto-detect login (poll for logged-in marke
·
back to Pattern Vault
·
capture-session: require POSITIVE auth marker (kill false-po 4b93b71 →