gemini-proxy-client 1.0.3 → 1.0.4

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.
@@ -129,27 +129,36 @@ export class BrowserManager {
129
129
  if (!this.page)
130
130
  throw new Error('Browser not launched');
131
131
  // 等待页面完全加载
132
- await sleep(5000);
133
- // 尝试多种方式找到连接按钮
132
+ await sleep(3000);
133
+ // 第一步:点击 "Continue to the app" 按钮(如果存在)
134
+ try {
135
+ const continueButton = await this.page.waitForSelector('button:has-text("Continue to the app")', { timeout: 5000 });
136
+ if (continueButton) {
137
+ await continueButton.click();
138
+ console.log(chalk.green('✅ 点击了 "Continue to the app" 按钮'));
139
+ await sleep(3000); // 等待页面切换
140
+ }
141
+ }
142
+ catch (e) {
143
+ // 按钮不存在,可能已经在 app 页面了
144
+ }
145
+ // 第二步:设置服务器地址(如果有输入框)
146
+ await this.setServerAddress();
147
+ // 第三步:点击 Connect WS 按钮
134
148
  const buttonSelectors = [
135
- 'button:has-text("Connect WS")', // 实际按钮文字
136
- 'button[aria-label="Connect WebSocket Proxy"]', // aria-label
149
+ 'button[aria-label="Connect WebSocket Proxy"]', // aria-label 最准确
137
150
  'button[title="Connect WebSocket Proxy"]', // title 属性
138
- 'button:has-text("ws connect")',
139
- 'button:has-text("connect")',
151
+ 'button:has-text("Connect WS")', // 按钮文字
140
152
  'button.bg-green-500', // 绿色按钮
141
153
  ];
142
154
  let clicked = false;
143
- // 先尝试设置服务器地址 (如果有输入框)
144
- await this.setServerAddress();
145
155
  for (const selector of buttonSelectors) {
146
156
  try {
147
- // 使用 waitForSelector 等待按钮出现
148
- const button = await this.page.waitForSelector(selector, { timeout: 3000 });
157
+ const button = await this.page.waitForSelector(selector, { timeout: 5000 });
149
158
  if (button) {
150
159
  await button.click();
151
160
  clicked = true;
152
- console.log(chalk.green(`✅ 找到并点击了按钮: ${selector}`));
161
+ console.log(chalk.green(`✅ 点击了连接按钮`));
153
162
  break;
154
163
  }
155
164
  }
@@ -158,9 +167,6 @@ export class BrowserManager {
158
167
  }
159
168
  }
160
169
  if (!clicked) {
161
- // 打印页面上所有按钮,帮助调试
162
- const buttons = await this.page.$$eval('button', (btns) => btns.map(b => ({ text: b.textContent?.trim(), class: b.className, title: b.title })));
163
- console.log(chalk.gray('页面上的按钮:'), JSON.stringify(buttons, null, 2));
164
170
  console.log(chalk.yellow('⚠️ 未找到连接按钮,请手动点击连接'));
165
171
  }
166
172
  // 等待连接建立
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-proxy-client",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Gemini Proxy Build App 客户端 - 使用 Camoufox 自动保持连接",
5
5
  "main": "dist/index.js",
6
6
  "bin": {