tt-help-cli-ycl 1.3.11 → 1.3.13
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/README.md +17 -17
- package/cli.js +9 -9
- package/package.json +45 -46
- package/{bat → scripts}/run-explore.bat +68 -68
- package/{bat → scripts}/run-explore.ps1 +81 -81
- package/{bat → scripts}/run-explore.sh +73 -73
- package/scripts/test-captcha-lib.mjs +68 -0
- package/scripts/test-captcha.mjs +81 -0
- package/scripts/test-incognito-lib.mjs +36 -0
- package/scripts/test-login-state.mjs +128 -0
- package/scripts/test-safe-click.mjs +45 -0
- package/src/cli/auto.js +186 -157
- package/src/cli/config.js +116 -0
- package/src/cli/explore-default.js +83 -0
- package/src/cli/explore.js +227 -181
- package/src/cli/progress.js +111 -111
- package/src/cli/refresh.js +216 -0
- package/src/cli/scrape.js +47 -47
- package/src/cli/utils.js +18 -18
- package/src/cli/videos.js +41 -41
- package/src/cli/watch.js +31 -31
- package/src/lib/args.js +456 -391
- package/src/lib/browser/anti-detect.js +23 -23
- package/src/lib/browser/cdp.js +194 -142
- package/src/lib/browser/launch.js +43 -43
- package/src/lib/browser/page.js +146 -87
- package/src/lib/constants.js +119 -119
- package/src/lib/delay.js +54 -54
- package/src/lib/explore-fetch.js +118 -118
- package/src/lib/fetcher.js +45 -45
- package/src/lib/filter.js +66 -66
- package/src/lib/io.js +54 -54
- package/src/lib/output.js +80 -80
- package/src/{scraper/modules/page-error-detector.mjs → lib/page-error-detector.js} +70 -70
- package/src/lib/parser.js +47 -47
- package/src/lib/retry.js +45 -45
- package/src/lib/scrape.js +40 -40
- package/src/{scraper/modules/scroll-collector.mjs → lib/scroll-collector.js} +231 -189
- package/src/lib/url.js +52 -52
- package/src/main.js +48 -0
- package/src/results/user-videos-bar.lar.lar.moeta.json +37 -0
- package/src/scraper/{auto-core.mjs → auto-core.js} +203 -194
- package/src/scraper/{core.mjs → core.js} +211 -190
- package/src/scraper/{explore-core.mjs → explore-core.js} +180 -171
- package/src/scraper/modules/{captcha-handler.mjs → captcha-handler.js} +114 -114
- package/src/scraper/modules/{comment-extractor.mjs → comment-extractor.js} +74 -69
- package/src/scraper/modules/{follow-extractor.mjs → follow-extractor.js} +121 -121
- package/src/scraper/modules/{guess-extractor.mjs → guess-extractor.js} +51 -51
- package/src/scraper/modules/page-error-detector.js +1 -0
- package/src/scraper/modules/{page-helpers.mjs → page-helpers.js} +48 -48
- package/src/scraper/modules/scroll-collector.js +8 -0
- package/src/scraper/refresh-core.js +179 -0
- package/src/videos/{core.mjs → core.js} +126 -126
- package/src/watch/data-store.js +431 -0
- package/src/watch/public/index.html +721 -690
- package/src/watch/{server.mjs → server.js} +484 -349
- package/src/main.mjs +0 -234
- package/src/test-auto-follow.cjs +0 -109
- package/src/test-extractors.cjs +0 -75
- package/src/test-follow.cjs +0 -41
- package/src/watch/data-store.mjs +0 -274
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export function getAntiDetectScript() {
|
|
2
|
-
return () => {
|
|
3
|
-
Object.defineProperty(navigator, 'webdriver', { get: () => false });
|
|
4
|
-
|
|
5
|
-
if (!window.chrome) {
|
|
6
|
-
window.chrome = { runtime: {} };
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const originalQuery = window.navigator.permissions.query;
|
|
10
|
-
window.navigator.permissions.query = (params) =>
|
|
11
|
-
params.name === 'notifications'
|
|
12
|
-
? Promise.resolve({ state: Notification.permission })
|
|
13
|
-
: originalQuery(params);
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(navigator, 'languages', {
|
|
16
|
-
get: () => ['en-US', 'en'],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(navigator, 'plugins', {
|
|
20
|
-
get: () => [1, 2, 3, 4, 5],
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|
|
1
|
+
export function getAntiDetectScript() {
|
|
2
|
+
return () => {
|
|
3
|
+
Object.defineProperty(navigator, 'webdriver', { get: () => false });
|
|
4
|
+
|
|
5
|
+
if (!window.chrome) {
|
|
6
|
+
window.chrome = { runtime: {} };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const originalQuery = window.navigator.permissions.query;
|
|
10
|
+
window.navigator.permissions.query = (params) =>
|
|
11
|
+
params.name === 'notifications'
|
|
12
|
+
? Promise.resolve({ state: Notification.permission })
|
|
13
|
+
: originalQuery(params);
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(navigator, 'languages', {
|
|
16
|
+
get: () => ['en-US', 'en'],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(navigator, 'plugins', {
|
|
20
|
+
get: () => [1, 2, 3, 4, 5],
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
package/src/lib/browser/cdp.js
CHANGED
|
@@ -1,142 +1,194 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
command = '
|
|
24
|
-
} else {
|
|
25
|
-
command = '
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
command = '
|
|
50
|
-
} else {
|
|
51
|
-
command = '
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return
|
|
142
|
-
}
|
|
1
|
+
import { exec } from 'child_process';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { chromium } from 'playwright';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_CDP_PORT = 9222;
|
|
9
|
+
const DEFAULT_USER_DATA_DIR = path.join(os.homedir(), 'Library', 'Application Support', 'Microsoft Edge For Testing');
|
|
10
|
+
|
|
11
|
+
function getEdgePath() {
|
|
12
|
+
const platform = os.platform();
|
|
13
|
+
if (platform === 'darwin') return '"Microsoft Edge"';
|
|
14
|
+
if (platform === 'win32') return 'msedge.exe';
|
|
15
|
+
return 'msedge';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isEdgeRunning() {
|
|
19
|
+
return new Promise(resolve => {
|
|
20
|
+
const platform = os.platform();
|
|
21
|
+
let command;
|
|
22
|
+
if (platform === 'darwin') {
|
|
23
|
+
command = 'ps aux | grep -q "[M]icrosoft Edge.app/Contents/MacOS/Microsoft Edge" 2>/dev/null';
|
|
24
|
+
} else if (platform === 'win32') {
|
|
25
|
+
command = 'tasklist /FI "IMAGENAME eq msedge.exe" 2>nul | findstr /I msedge';
|
|
26
|
+
} else {
|
|
27
|
+
command = 'pgrep -f msedge > /dev/null 2>&1';
|
|
28
|
+
}
|
|
29
|
+
exec(command, (err) => resolve(!err));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function checkCDPPort(port) {
|
|
34
|
+
return new Promise(resolve => {
|
|
35
|
+
const req = http.get(`http://127.0.0.1:${port}/json`, res => {
|
|
36
|
+
res.on('data', () => {});
|
|
37
|
+
res.on('end', () => resolve(res.statusCode === 200));
|
|
38
|
+
});
|
|
39
|
+
req.on('error', () => resolve(false));
|
|
40
|
+
req.setTimeout(3000, () => { resolve(false); req.destroy(); });
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function checkEdgeArgs() {
|
|
45
|
+
return new Promise(resolve => {
|
|
46
|
+
const platform = os.platform();
|
|
47
|
+
let command;
|
|
48
|
+
if (platform === 'darwin') {
|
|
49
|
+
command = 'ps aux | grep "[M]icrosoft Edge" | grep -v "Helper\\|crashpad" | grep "user-data-dir"';
|
|
50
|
+
} else if (platform === 'win32') {
|
|
51
|
+
command = 'wmic process where "name like \\"%msedge%\\"" get commandline | findstr "user-data-dir"';
|
|
52
|
+
} else {
|
|
53
|
+
command = 'ps aux | grep "[m]sedge" | grep -v "Helper\\|crashpad" | grep "user-data-dir"';
|
|
54
|
+
}
|
|
55
|
+
exec(command, (err, stdout) => resolve(!err && stdout.trim().length > 0));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function killEdgeProcesses(targetDir) {
|
|
60
|
+
return new Promise(resolve => {
|
|
61
|
+
const platform = os.platform();
|
|
62
|
+
let command;
|
|
63
|
+
if (platform === 'darwin') {
|
|
64
|
+
if (targetDir) {
|
|
65
|
+
let pids = '';
|
|
66
|
+
try {
|
|
67
|
+
// ps aux 输出中 --user-data-dir= 后面没有引号
|
|
68
|
+
// 用路径精确匹配,结尾加空格或行尾避免子串误杀
|
|
69
|
+
const escapedDir = targetDir.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
70
|
+
pids = execSync(
|
|
71
|
+
`ps aux | grep "[M]icrosoft Edge" | grep -v "Helper\\|crashpad" | grep -E -- '--user-data-dir=${escapedDir}($|[^A-Za-z0-9_])' | awk '{print $2}'`
|
|
72
|
+
).toString().trim();
|
|
73
|
+
} catch (e) {
|
|
74
|
+
pids = '';
|
|
75
|
+
}
|
|
76
|
+
if (pids) {
|
|
77
|
+
command = `kill -9 ${pids} 2>/dev/null; rm -f ~/Library/Caches/Microsoft\\ Edge/Singleton*; true`;
|
|
78
|
+
} else {
|
|
79
|
+
command = 'true';
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
command = 'killall -9 "Microsoft Edge" 2>/dev/null; rm -f ~/Library/Caches/Microsoft\\ Edge/Singleton*; true';
|
|
83
|
+
}
|
|
84
|
+
} else if (platform === 'win32') {
|
|
85
|
+
command = 'taskkill /F /IM msedge.exe 2>nul || exit 0';
|
|
86
|
+
} else {
|
|
87
|
+
if (targetDir) {
|
|
88
|
+
const escapedDir = targetDir.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
89
|
+
command = `ps aux | grep msedge | grep -v Helper | grep -E -- '--user-data-dir=${escapedDir}($|[^A-Za-z0-9_])' | awk '{print $2}' | xargs -r kill -9 2>/dev/null; true`;
|
|
90
|
+
} else {
|
|
91
|
+
command = 'pkill -9 -f msedge 2>/dev/null; true';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exec(command, () => resolve());
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function launchEdgeWithCDP(port, userDataDir) {
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
const platform = os.platform();
|
|
101
|
+
const edgePath = getEdgePath();
|
|
102
|
+
let command;
|
|
103
|
+
|
|
104
|
+
const extraArgs = [
|
|
105
|
+
`--remote-debugging-port=${port}`,
|
|
106
|
+
`--user-data-dir="${userDataDir}"`,
|
|
107
|
+
'--disable-blink-features=AutomationControlled',
|
|
108
|
+
'--no-first-run',
|
|
109
|
+
'--no-default-browser-check',
|
|
110
|
+
'--password-store=basic',
|
|
111
|
+
'--disable-background-mode',
|
|
112
|
+
'--disable-component-update',
|
|
113
|
+
'--disable-crash-reporter',
|
|
114
|
+
'--disable-breakpad',
|
|
115
|
+
'--disable-background-networking',
|
|
116
|
+
'--disable-sync',
|
|
117
|
+
].join(' ');
|
|
118
|
+
|
|
119
|
+
if (platform === 'darwin') {
|
|
120
|
+
command = `open -a ${edgePath} --new --args ${extraArgs}`;
|
|
121
|
+
} else if (platform === 'win32') {
|
|
122
|
+
command = `start msedge ${extraArgs}`;
|
|
123
|
+
} else {
|
|
124
|
+
command = `msedge ${extraArgs} &`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
exec(command, (err) => {
|
|
128
|
+
if (err) reject(new Error(`启动 Edge 浏览器失败: ${err.message}`));
|
|
129
|
+
else resolve();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function waitForCDP(port, timeout = 30000, interval = 1000) {
|
|
135
|
+
const start = Date.now();
|
|
136
|
+
while (Date.now() - start < timeout) {
|
|
137
|
+
const ready = await checkCDPPort(port);
|
|
138
|
+
if (ready) return true;
|
|
139
|
+
await new Promise(r => setTimeout(r, interval));
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { killEdgeProcesses };
|
|
145
|
+
|
|
146
|
+
export async function ensureBrowserReady(options = {}) {
|
|
147
|
+
const port = options.port || DEFAULT_CDP_PORT;
|
|
148
|
+
const userDataDir = options.userDataDir || DEFAULT_USER_DATA_DIR;
|
|
149
|
+
const isCustom = port !== DEFAULT_CDP_PORT || !!options.userDataDir;
|
|
150
|
+
|
|
151
|
+
const isReady = await checkCDPPort(port);
|
|
152
|
+
let needLaunch = !isReady;
|
|
153
|
+
|
|
154
|
+
if (!needLaunch) {
|
|
155
|
+
if (!isCustom) {
|
|
156
|
+
const edgeArgsValid = await checkEdgeArgs();
|
|
157
|
+
if (!edgeArgsValid) {
|
|
158
|
+
console.error(`Edge 已运行但启动参数不完整,正在重启端口 ${port}...`);
|
|
159
|
+
await killEdgeProcesses(userDataDir);
|
|
160
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
161
|
+
needLaunch = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (needLaunch) {
|
|
167
|
+
if (isCustom) {
|
|
168
|
+
console.error(`CDP 端口 ${port} 未就绪,正在启动 Edge 浏览器...`);
|
|
169
|
+
} else {
|
|
170
|
+
const edgeRunning = await isEdgeRunning();
|
|
171
|
+
if (edgeRunning) {
|
|
172
|
+
console.error(`Edge 已运行但 CDP 端口 ${port} 未启用,正在重启...`);
|
|
173
|
+
await killEdgeProcesses(userDataDir);
|
|
174
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
175
|
+
} else {
|
|
176
|
+
console.error(`CDP 端口 ${port} 未就绪,正在启动 Edge 浏览器...`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
await launchEdgeWithCDP(port, userDataDir);
|
|
180
|
+
|
|
181
|
+
console.error('等待浏览器启动...');
|
|
182
|
+
const launched = await waitForCDP(port);
|
|
183
|
+
if (!launched) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`等待 CDP 端口 ${port} 超时。请确认 Edge 浏览器已安装,\n` +
|
|
186
|
+
`或手动启动: Microsoft Edge --remote-debugging-port=${port} [参见 cdp.js extraArgs]`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
console.error('浏览器启动成功');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const browser = await chromium.connectOverCDP(`http://127.0.0.1:${port}`);
|
|
193
|
+
return browser;
|
|
194
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { accessSync } from 'fs';
|
|
2
|
-
|
|
3
|
-
export function detectBrowser() {
|
|
4
|
-
const isMac = process.platform === 'darwin';
|
|
5
|
-
const isWin = process.platform === 'win32';
|
|
6
|
-
const isLinux = process.platform === 'linux';
|
|
7
|
-
|
|
8
|
-
const paths = [];
|
|
9
|
-
|
|
10
|
-
if (isMac) {
|
|
11
|
-
paths.push(
|
|
12
|
-
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
13
|
-
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
|
14
|
-
'/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
|
15
|
-
'/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
|
|
16
|
-
);
|
|
17
|
-
} else if (isWin) {
|
|
18
|
-
const localAppData = process.env.LOCALAPPDATA || '';
|
|
19
|
-
const programFiles = process.env.PROGRAMFILES || '';
|
|
20
|
-
const programFilesX86 = process.env['PROGRAMFILES(X86)'] || '';
|
|
21
|
-
paths.push(
|
|
22
|
-
`${programFiles}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
23
|
-
`${programFilesX86}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
24
|
-
`${localAppData}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
25
|
-
`${programFiles}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
26
|
-
`${programFilesX86}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
27
|
-
);
|
|
28
|
-
} else if (isLinux) {
|
|
29
|
-
paths.push(
|
|
30
|
-
'/usr/bin/google-chrome',
|
|
31
|
-
'/usr/bin/google-chrome-stable',
|
|
32
|
-
'/usr/bin/chromium-browser',
|
|
33
|
-
'/usr/bin/chromium',
|
|
34
|
-
'/snap/bin/chromium',
|
|
35
|
-
'/usr/bin/microsoft-edge',
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
for (const p of paths) {
|
|
40
|
-
try { accessSync(p); return p; } catch { /* not found */ }
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
1
|
+
import { accessSync } from 'fs';
|
|
2
|
+
|
|
3
|
+
export function detectBrowser() {
|
|
4
|
+
const isMac = process.platform === 'darwin';
|
|
5
|
+
const isWin = process.platform === 'win32';
|
|
6
|
+
const isLinux = process.platform === 'linux';
|
|
7
|
+
|
|
8
|
+
const paths = [];
|
|
9
|
+
|
|
10
|
+
if (isMac) {
|
|
11
|
+
paths.push(
|
|
12
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
13
|
+
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
|
14
|
+
'/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
|
15
|
+
'/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
|
|
16
|
+
);
|
|
17
|
+
} else if (isWin) {
|
|
18
|
+
const localAppData = process.env.LOCALAPPDATA || '';
|
|
19
|
+
const programFiles = process.env.PROGRAMFILES || '';
|
|
20
|
+
const programFilesX86 = process.env['PROGRAMFILES(X86)'] || '';
|
|
21
|
+
paths.push(
|
|
22
|
+
`${programFiles}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
23
|
+
`${programFilesX86}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
24
|
+
`${localAppData}\\Google\\Chrome\\Application\\chrome.exe`,
|
|
25
|
+
`${programFiles}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
26
|
+
`${programFilesX86}\\Microsoft\\Edge\\Application\\msedge.exe`,
|
|
27
|
+
);
|
|
28
|
+
} else if (isLinux) {
|
|
29
|
+
paths.push(
|
|
30
|
+
'/usr/bin/google-chrome',
|
|
31
|
+
'/usr/bin/google-chrome-stable',
|
|
32
|
+
'/usr/bin/chromium-browser',
|
|
33
|
+
'/usr/bin/chromium',
|
|
34
|
+
'/snap/bin/chromium',
|
|
35
|
+
'/usr/bin/microsoft-edge',
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const p of paths) {
|
|
40
|
+
try { accessSync(p); return p; } catch { /* not found */ }
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|