gemini-proxy-client 1.0.2 → 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(2000);
133
- // 查找并修改 WebSocket 连接地址 (如果需要)
134
- // 这取决于 Build App 的实现方式
135
- // 尝试多种方式找到连接按钮
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 按钮
136
148
  const buttonSelectors = [
137
- 'button:has-text("Connect WS")', // 实际按钮文字
138
- 'button[aria-label="Connect WebSocket Proxy"]', // aria-label
149
+ 'button[aria-label="Connect WebSocket Proxy"]', // aria-label 最准确
139
150
  'button[title="Connect WebSocket Proxy"]', // title 属性
140
- 'button:has-text("ws connect")',
141
- 'button:has-text("connect")',
151
+ 'button:has-text("Connect WS")', // 按钮文字
142
152
  'button.bg-green-500', // 绿色按钮
143
153
  ];
144
154
  let clicked = false;
145
155
  for (const selector of buttonSelectors) {
146
156
  try {
147
- const button = await this.page.$(selector);
157
+ const button = await this.page.waitForSelector(selector, { timeout: 5000 });
148
158
  if (button) {
149
- // 先尝试设置服务器地址 (如果有输入框)
150
- await this.setServerAddress();
151
159
  await button.click();
152
160
  clicked = true;
161
+ console.log(chalk.green(`✅ 点击了连接按钮`));
153
162
  break;
154
163
  }
155
164
  }
@@ -158,15 +167,6 @@ export class BrowserManager {
158
167
  }
159
168
  }
160
169
  if (!clicked) {
161
- // 如果找不到按钮,可能需要通过其他方式触发连接
162
- // 尝试在页面中执行 JavaScript
163
- await this.page.evaluate(({ serverUrl, token }) => {
164
- // 尝试找到全局的连接函数或 WebSocket 实例
165
- const wsUrl = `${serverUrl}?auth_token=${token}`;
166
- console.log('Attempting to connect to:', wsUrl);
167
- // 这里的实现取决于 Build App 的具体代码结构
168
- // 可能需要根据实际情况调整
169
- }, { serverUrl: this.options.serverUrl, token: this.options.token });
170
170
  console.log(chalk.yellow('⚠️ 未找到连接按钮,请手动点击连接'));
171
171
  }
172
172
  // 等待连接建立
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-proxy-client",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Gemini Proxy Build App 客户端 - 使用 Camoufox 自动保持连接",
5
5
  "main": "dist/index.js",
6
6
  "bin": {