tt-help-cli-ycl 1.3.72 → 1.3.74
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/cli/attach.js +5 -3
- package/src/cli/open.js +51 -3
- package/src/lib/args.js +4 -0
- package/src/lib/parse-ssr.mjs +1 -0
- package/src/watch/data-store.js +346 -155
- package/src/watch/public/app.js +194 -126
- package/src/watch/public/index.html +7 -0
- package/src/watch/server.js +50 -3
package/package.json
CHANGED
package/src/cli/attach.js
CHANGED
|
@@ -289,12 +289,14 @@ export async function handleAttach(options) {
|
|
|
289
289
|
const task = successTasks.find(
|
|
290
290
|
(t) => t.uniqueId === r.uniqueId,
|
|
291
291
|
);
|
|
292
|
-
|
|
292
|
+
const info = task?.info;
|
|
293
|
+
const sellerTag = info?.ttSeller ? " [商家ttSeller=true]" : "";
|
|
294
|
+
if (info && info.error) {
|
|
293
295
|
attachLog(
|
|
294
|
-
`
|
|
296
|
+
` ⚠${sellerTag} @${r.uniqueId} 已记录 (statusCode=${info.statusCode})`,
|
|
295
297
|
);
|
|
296
298
|
} else {
|
|
297
|
-
attachLog(`
|
|
299
|
+
attachLog(` ✓${sellerTag} @${r.uniqueId} 已提交更新`);
|
|
298
300
|
}
|
|
299
301
|
} else {
|
|
300
302
|
failCount++;
|
package/src/cli/open.js
CHANGED
|
@@ -2,12 +2,14 @@ import { ensureBrowserReady, killEdgeProcesses } from "../lib/browser/cdp.js";
|
|
|
2
2
|
import { getOrCreatePage } from "../lib/browser/page.js";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import os from "os";
|
|
5
|
+
import http from "http";
|
|
6
|
+
import readline from "readline";
|
|
5
7
|
|
|
6
8
|
const BASE_PORT = 9222;
|
|
7
9
|
const TOTAL_ACCOUNTS = 10;
|
|
8
10
|
|
|
9
11
|
export async function handleOpen(parsed) {
|
|
10
|
-
const { openPort, openList } = parsed;
|
|
12
|
+
const { openPort, openList, openProxy } = parsed;
|
|
11
13
|
|
|
12
14
|
if (openList) {
|
|
13
15
|
console.error("内置浏览器配置:");
|
|
@@ -31,8 +33,9 @@ export async function handleOpen(parsed) {
|
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
if (!openPort) {
|
|
34
|
-
console.error("用法: tt-help open <端口>");
|
|
36
|
+
console.error("用法: tt-help open <端口> [--proxy <代理地址>]");
|
|
35
37
|
console.error("示例: tt-help open 9222");
|
|
38
|
+
console.error(" tt-help open 9222 --proxy http://127.0.0.1:7890");
|
|
36
39
|
console.error("");
|
|
37
40
|
console.error('运行 "tt-help open --list" 查看内置浏览器配置');
|
|
38
41
|
process.exit(1);
|
|
@@ -52,7 +55,22 @@ export async function handleOpen(parsed) {
|
|
|
52
55
|
`Microsoft Edge For Testing_${profile}`,
|
|
53
56
|
);
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
// 检查端口是否已被占用
|
|
59
|
+
const portInUse = await checkCDPPort(port);
|
|
60
|
+
if (portInUse) {
|
|
61
|
+
console.error(`⚠ 端口 ${port} 已有浏览器在运行中`);
|
|
62
|
+
const answer = await askQuestion("是否要继续连接到该浏览器?(y/N) ");
|
|
63
|
+
if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
|
|
64
|
+
console.error("已取消");
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
console.error(`正在连接到端口 ${port} 的浏览器...`);
|
|
68
|
+
} else {
|
|
69
|
+
console.error(
|
|
70
|
+
`正在启动浏览器... 端口: ${port}, profile: ${profile}${openProxy ? ", 代理: " + openProxy : ""}`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
56
74
|
console.error(`userDataDir: ${userDataDir}`);
|
|
57
75
|
console.error("");
|
|
58
76
|
console.error("启动后请在浏览器中登录 TikTok 账户");
|
|
@@ -66,6 +84,9 @@ export async function handleOpen(parsed) {
|
|
|
66
84
|
const cdpOptions = {};
|
|
67
85
|
cdpOptions.port = port;
|
|
68
86
|
cdpOptions.userDataDir = userDataDir;
|
|
87
|
+
if (openProxy) {
|
|
88
|
+
cdpOptions.proxyServer = openProxy;
|
|
89
|
+
}
|
|
69
90
|
|
|
70
91
|
browser = await ensureBrowserReady(cdpOptions);
|
|
71
92
|
|
|
@@ -108,3 +129,30 @@ export async function handleOpen(parsed) {
|
|
|
108
129
|
process.exit(1);
|
|
109
130
|
}
|
|
110
131
|
}
|
|
132
|
+
|
|
133
|
+
function checkCDPPort(port) {
|
|
134
|
+
return new Promise((resolve) => {
|
|
135
|
+
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
136
|
+
res.on("data", () => {});
|
|
137
|
+
res.on("end", () => resolve(res.statusCode === 200));
|
|
138
|
+
});
|
|
139
|
+
req.on("error", () => resolve(false));
|
|
140
|
+
req.setTimeout(3000, () => {
|
|
141
|
+
resolve(false);
|
|
142
|
+
req.destroy();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function askQuestion(question) {
|
|
148
|
+
return new Promise((resolve) => {
|
|
149
|
+
const rl = readline.createInterface({
|
|
150
|
+
input: process.stdin,
|
|
151
|
+
output: process.stderr,
|
|
152
|
+
});
|
|
153
|
+
rl.question(question, (answer) => {
|
|
154
|
+
rl.close();
|
|
155
|
+
resolve(answer);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
package/src/lib/args.js
CHANGED
|
@@ -575,11 +575,14 @@ function parseAttachArgs(args) {
|
|
|
575
575
|
function parseOpenArgs(args) {
|
|
576
576
|
let openPort = null;
|
|
577
577
|
let openList = false;
|
|
578
|
+
let openProxy = null;
|
|
578
579
|
|
|
579
580
|
for (let i = 0; i < args.length; i++) {
|
|
580
581
|
const arg = args[i];
|
|
581
582
|
if (arg === "--list") {
|
|
582
583
|
openList = true;
|
|
584
|
+
} else if (arg === "--proxy") {
|
|
585
|
+
openProxy = args[++i];
|
|
583
586
|
} else if (!arg.startsWith("-")) {
|
|
584
587
|
openPort = arg;
|
|
585
588
|
}
|
|
@@ -589,6 +592,7 @@ function parseOpenArgs(args) {
|
|
|
589
592
|
subcommand: "open",
|
|
590
593
|
openPort,
|
|
591
594
|
openList,
|
|
595
|
+
openProxy,
|
|
592
596
|
urls: [],
|
|
593
597
|
outputFormat: "json",
|
|
594
598
|
exploreCount: 0,
|
package/src/lib/parse-ssr.mjs
CHANGED
|
@@ -70,6 +70,7 @@ export function parseUserInfo(rawHtml) {
|
|
|
70
70
|
privateAccount: u.privateAccount,
|
|
71
71
|
language: u.language,
|
|
72
72
|
bio: u.signature || "",
|
|
73
|
+
bioLink: u.bioLink?.link || u.bioLink?.url || u.bioLink || null,
|
|
73
74
|
avatar: u.avatarLarger || u.avatarMedium || u.avatarThumb || "",
|
|
74
75
|
followerCount: s.followerCount,
|
|
75
76
|
followingCount: s.followingCount,
|