@@ -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 }
0 commit comments