Skip to content

Commit 2ff7859

Browse files
committed
fix: dashboard 优先点"使用"按钮进入聊天
1 parent 879e40e commit 2ff7859

2 files changed

Lines changed: 18 additions & 26 deletions

File tree

mcp-servers/ai-services/chatgpt-mirror/dist/index.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,19 @@ async function askChatGPT(question, attachments) {
100100
await startBtn.first().click({ timeout: 3000 }).catch(() => { });
101101
await sleep(3000);
102102
}
103-
// 如果跳到 dashboard,刷新后点 ChatGPT 的 "Use" 或 "使用"
104-
if (pg.url().includes("/dashboard") || pg.url().includes("2233.ai/?redirect")) {
103+
// 如果跳到 dashboard,先刷新确保状态,再点"使用"或 a[href="/chatgtp"]
104+
if (pg.url().includes("2233.ai") && !pg.url().includes("claude")) {
105105
await showToast(pg, "正在进入 ChatGPT…");
106106
await pg.goto("https://2233.ai/dashboard", { waitUntil: "domcontentloaded", timeout: 15000 }).catch(() => { });
107-
await sleep(2000);
108-
// 找到 ChatGPT 旁边的 "Use" / "使用" 按钮
109-
const chaturl = pg.locator('a[href*="chatgpt"], a[href*="chat"]').first();
110-
if (await chaturl.isVisible({ timeout: 2000 }).catch(() => false)) {
111-
// 点 ChatGPT 链接
112-
await chaturl.click({ timeout: 3000 }).catch(() => { });
107+
await sleep(3000);
108+
// 先找"使用"/"Use"按钮(dashboard 上每个服务旁的按钮)
109+
const useBtn = pg.locator('button:has-text("使用"), button:has-text("Use")').first();
110+
if (await useBtn.isVisible({ timeout: 2000 }).catch(() => false)) {
111+
await useBtn.click({ timeout: 3000 }).catch(() => { });
113112
}
114113
else {
115-
// 兜底:找页面上任意 Use/使用 按钮
116-
const useBtn = pg.locator('button:has-text("Use"), button:has-text("使用")').first();
117-
if (await useBtn.isVisible({ timeout: 2000 }).catch(() => false)) {
118-
await useBtn.click({ timeout: 3000 }).catch(() => { });
119-
}
114+
// 兜底:点 ChatGPT 链接
115+
await pg.locator('a[href="/chatgtp"]').first().evaluate((el) => el.click()).catch(() => { });
120116
}
121117
await sleep(4000);
122118
}

mcp-servers/ai-services/chatgpt-mirror/src/index.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,18 @@ async function askChatGPT(question: string, attachments?: string[]): Promise<str
8686
await sleep(3000);
8787
}
8888

89-
// 如果跳到 dashboard,刷新后点 ChatGPT 的 "Use" 或 "使用"
90-
if (pg.url().includes("/dashboard") || pg.url().includes("2233.ai/?redirect")) {
89+
// 如果跳到 dashboard,先刷新确保状态,再点"使用"或 a[href="/chatgtp"]
90+
if (pg.url().includes("2233.ai") && !pg.url().includes("claude")) {
9191
await showToast(pg, "正在进入 ChatGPT…");
9292
await pg.goto("https://2233.ai/dashboard", { waitUntil: "domcontentloaded", timeout: 15000 }).catch(() => {});
93-
await sleep(2000);
94-
// 找到 ChatGPT 旁边的 "Use" / "使用" 按钮
95-
const chaturl = pg.locator('a[href*="chatgpt"], a[href*="chat"]').first();
96-
if (await chaturl.isVisible({ timeout: 2000 }).catch(() => false)) {
97-
// 点 ChatGPT 链接
98-
await chaturl.click({ timeout: 3000 }).catch(() => {});
93+
await sleep(3000);
94+
// 先找"使用"/"Use"按钮(dashboard 上每个服务旁的按钮)
95+
const useBtn = pg.locator('button:has-text("使用"), button:has-text("Use")').first();
96+
if (await useBtn.isVisible({ timeout: 2000 }).catch(() => false)) {
97+
await useBtn.click({ timeout: 3000 }).catch(() => {});
9998
} else {
100-
// 兜底:找页面上任意 Use/使用 按钮
101-
const useBtn = pg.locator('button:has-text("Use"), button:has-text("使用")').first();
102-
if (await useBtn.isVisible({ timeout: 2000 }).catch(() => false)) {
103-
await useBtn.click({ timeout: 3000 }).catch(() => {});
104-
}
99+
// 兜底:点 ChatGPT 链接
100+
await pg.locator('a[href="/chatgtp"]').first().evaluate((el: HTMLElement) => el.click()).catch(() => {});
105101
}
106102
await sleep(4000);
107103
}

0 commit comments

Comments
 (0)