@lightcone-ai/daemon 0.9.30 → 0.9.32
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.
|
@@ -42,11 +42,22 @@ export class XhsAdapter {
|
|
|
42
42
|
|
|
43
43
|
// Navigate to publish page
|
|
44
44
|
await cdp.send('Page.navigate', { url: 'https://creator.xiaohongshu.com/publish/publish' });
|
|
45
|
-
await
|
|
45
|
+
await sleep(3000);
|
|
46
|
+
|
|
47
|
+
// Check if we got redirected away (login expired)
|
|
48
|
+
const urlAfterNav = await this._getUrl();
|
|
49
|
+
if (!urlAfterNav.includes('creator.xiaohongshu.com/publish')) {
|
|
50
|
+
throw new Error(`LOGIN_EXPIRED: 跳转到了 ${urlAfterNav},请重新扫码连接小红书`);
|
|
51
|
+
}
|
|
46
52
|
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
// Wait for upload area with multiple fallback selectors
|
|
54
|
+
await this._waitForAny([
|
|
55
|
+
'input[type="file"]',
|
|
56
|
+
'[class*="upload"]',
|
|
57
|
+
'[class*="Upload"]',
|
|
58
|
+
'[class*="uploader"]',
|
|
59
|
+
'.upload-input',
|
|
60
|
+
], 15000);
|
|
50
61
|
|
|
51
62
|
// Upload images first (if any)
|
|
52
63
|
if (images.length > 0) {
|
|
@@ -99,10 +110,19 @@ export class XhsAdapter {
|
|
|
99
110
|
const cdp = this._cdp;
|
|
100
111
|
|
|
101
112
|
await cdp.send('Page.navigate', { url: 'https://creator.xiaohongshu.com/publish/publish?source=video' });
|
|
102
|
-
await
|
|
113
|
+
await sleep(3000);
|
|
103
114
|
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
115
|
+
const urlAfterNav = await this._getUrl();
|
|
116
|
+
if (!urlAfterNav.includes('creator.xiaohongshu.com/publish')) {
|
|
117
|
+
throw new Error(`LOGIN_EXPIRED: 跳转到了 ${urlAfterNav},请重新扫码连接小红书`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
await this._waitForAny([
|
|
121
|
+
'input[type="file"]',
|
|
122
|
+
'[class*="upload"]',
|
|
123
|
+
'[class*="Upload"]',
|
|
124
|
+
'[class*="uploader"]',
|
|
125
|
+
], 15000);
|
|
106
126
|
|
|
107
127
|
// Upload video
|
|
108
128
|
await this._uploadFiles([video], 'video');
|
|
@@ -143,6 +163,20 @@ export class XhsAdapter {
|
|
|
143
163
|
throw new Error(`Timeout waiting for selector: ${selector}`);
|
|
144
164
|
}
|
|
145
165
|
|
|
166
|
+
async _waitForAny(selectors, timeoutMs = 15000) {
|
|
167
|
+
const combined = selectors.join(', ');
|
|
168
|
+
const deadline = Date.now() + timeoutMs;
|
|
169
|
+
while (Date.now() < deadline) {
|
|
170
|
+
const result = await this._cdp.send('Runtime.evaluate', {
|
|
171
|
+
expression: `!!document.querySelector(${JSON.stringify(combined)})`,
|
|
172
|
+
returnByValue: true,
|
|
173
|
+
});
|
|
174
|
+
if (result.result?.value) return;
|
|
175
|
+
await sleep(500);
|
|
176
|
+
}
|
|
177
|
+
throw new Error(`Timeout waiting for any of: ${combined}`);
|
|
178
|
+
}
|
|
179
|
+
|
|
146
180
|
async _waitForText(text, timeoutMs = 8000) {
|
|
147
181
|
const deadline = Date.now() + timeoutMs;
|
|
148
182
|
while (Date.now() < deadline) {
|
package/package.json
CHANGED
package/src/browser-login.js
CHANGED
|
@@ -98,7 +98,7 @@ export class BrowserLoginSession {
|
|
|
98
98
|
`--remote-debugging-port=${CDP_PORT}`,
|
|
99
99
|
'--no-sandbox',
|
|
100
100
|
'--disable-dev-shm-usage',
|
|
101
|
-
'--headless=
|
|
101
|
+
'--headless=false',
|
|
102
102
|
`--user-data-dir=${this._profileDir}`,
|
|
103
103
|
'--window-size=800,900',
|
|
104
104
|
'--disable-blink-features=AutomationControlled',
|