@lightcone-ai/daemon 0.9.59 → 0.9.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/browser-login.js +31 -4
package/package.json
CHANGED
package/src/browser-login.js
CHANGED
|
@@ -18,6 +18,8 @@ export const PLATFORM_CONFIGS = {
|
|
|
18
18
|
// Use creator subdomain so the QR scan establishes a creator session directly.
|
|
19
19
|
// www.xiaohongshu.com session is separate — it cannot access creator.xiaohongshu.com.
|
|
20
20
|
loginUrl: 'https://creator.xiaohongshu.com',
|
|
21
|
+
// Creator login page defaults to password login; click QR tab first
|
|
22
|
+
qrTabSelector: ['.qrcode-box', '[class*="qrcode"]', '[class*="scan-login"]', '[class*="qr-login"]'],
|
|
21
23
|
getSessionValue: (cookies) => cookies.find(c => c.name === 'web_session')?.value ?? null,
|
|
22
24
|
isLoggedIn: (cookies, baseline) => {
|
|
23
25
|
const val = cookies.find(c => c.name === 'web_session')?.value ?? null;
|
|
@@ -129,7 +131,7 @@ export class BrowserLoginSession {
|
|
|
129
131
|
'--disable-dev-shm-usage',
|
|
130
132
|
'--headless=new',
|
|
131
133
|
`--user-data-dir=${this._profileDir}`,
|
|
132
|
-
'--window-size=
|
|
134
|
+
'--window-size=1280,900',
|
|
133
135
|
'--disable-blink-features=AutomationControlled',
|
|
134
136
|
'--disable-infobars',
|
|
135
137
|
'--disable-component-extensions-with-background-pages',
|
|
@@ -177,10 +179,35 @@ export class BrowserLoginSession {
|
|
|
177
179
|
|
|
178
180
|
await this.send('Page.navigate', { url: this._config.loginUrl });
|
|
179
181
|
|
|
180
|
-
// Wait for page to settle
|
|
182
|
+
// Wait for page to settle
|
|
183
|
+
await sleep(4000);
|
|
184
|
+
|
|
185
|
+
// Try to click the QR scan login tab if present (some platforms default to password login)
|
|
186
|
+
if (this._config.qrTabSelector) {
|
|
187
|
+
try {
|
|
188
|
+
const selectors = this._config.qrTabSelector;
|
|
189
|
+
await this.send('Runtime.evaluate', {
|
|
190
|
+
expression: `(function() {
|
|
191
|
+
const sels = ${JSON.stringify(selectors)};
|
|
192
|
+
for (const s of sels) {
|
|
193
|
+
const el = document.querySelector(s);
|
|
194
|
+
if (el) { el.click(); return s; }
|
|
195
|
+
}
|
|
196
|
+
// Also try text-based search
|
|
197
|
+
const all = [...document.querySelectorAll('a,button,span,div')];
|
|
198
|
+
const el = all.find(e => e.innerText?.trim() === '扫码登录' || e.innerText?.trim() === '二维码登录');
|
|
199
|
+
if (el) { el.click(); return 'text:' + el.innerText.trim(); }
|
|
200
|
+
return null;
|
|
201
|
+
})()`,
|
|
202
|
+
returnByValue: true,
|
|
203
|
+
});
|
|
204
|
+
await sleep(1000);
|
|
205
|
+
} catch {}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Record baseline session cookie value.
|
|
181
209
|
// XHS sets an anonymous web_session on first visit — we only trigger login_complete
|
|
182
210
|
// when the value CHANGES (real login replaces it with an authenticated session).
|
|
183
|
-
await sleep(4000);
|
|
184
211
|
const baselineCookies = await this.send('Network.getAllCookies', {});
|
|
185
212
|
const baselineSession = this._config.getSessionValue(baselineCookies.cookies ?? []);
|
|
186
213
|
|
|
@@ -224,7 +251,7 @@ export class BrowserLoginSession {
|
|
|
224
251
|
}
|
|
225
252
|
|
|
226
253
|
async screenshot() {
|
|
227
|
-
const result = await this.send('Page.captureScreenshot', { format: 'jpeg', quality:
|
|
254
|
+
const result = await this.send('Page.captureScreenshot', { format: 'jpeg', quality: 60 }, 10_000);
|
|
228
255
|
return result.data;
|
|
229
256
|
}
|
|
230
257
|
|