@lightcone-ai/daemon 0.9.14 → 0.9.15
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/xhs-login.js +17 -1
package/package.json
CHANGED
package/src/xhs-login.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { spawn } from 'child_process';
|
|
7
7
|
import { homedir } from 'os';
|
|
8
|
+
import { accessSync, constants as fsConstants } from 'fs';
|
|
8
9
|
import path from 'path';
|
|
9
10
|
import http from 'http';
|
|
10
11
|
import { WebSocket } from 'ws';
|
|
@@ -15,7 +16,22 @@ export function xhsProfileDir(userId) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const CDP_PORT = 9225;
|
|
18
|
-
|
|
19
|
+
function detectChrome() {
|
|
20
|
+
if (process.env.CHROME_BIN) return process.env.CHROME_BIN;
|
|
21
|
+
const candidates = [
|
|
22
|
+
'/usr/bin/google-chrome',
|
|
23
|
+
'/usr/bin/google-chrome-stable',
|
|
24
|
+
'/usr/bin/chromium-browser',
|
|
25
|
+
'/usr/bin/chromium',
|
|
26
|
+
'/snap/bin/chromium',
|
|
27
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
28
|
+
];
|
|
29
|
+
for (const p of candidates) {
|
|
30
|
+
try { accessSync(p, fsConstants.X_OK); return p; } catch {}
|
|
31
|
+
}
|
|
32
|
+
return candidates[0];
|
|
33
|
+
}
|
|
34
|
+
const CHROME_BIN = detectChrome();
|
|
19
35
|
const SCREENSHOT_INTERVAL_MS = 2000;
|
|
20
36
|
const LOGIN_CHECK_INTERVAL_MS = 3000;
|
|
21
37
|
|