gemini-proxy-client 1.0.10 → 1.0.11

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.
@@ -189,27 +189,31 @@ export class BrowserManager {
189
189
  catch (e) {
190
190
  // 忽略
191
191
  }
192
- // 查找按钮
193
- const buttons = await frame.$$('button');
194
- console.log(chalk.gray(` iframe 中找到 ${buttons.length} 个按钮`));
195
- for (const button of buttons) {
196
- try {
197
- const title = await button.getAttribute('title');
198
- const text = await button.textContent();
199
- console.log(chalk.gray(` 按钮: "${text?.trim()}" title="${title}"`));
200
- if (title === 'Connect WebSocket Proxy' || (text && text.includes('Connect WS'))) {
201
- // 使用 force: true 强制点击,忽略遮挡
202
- await button.click({ force: true });
203
- clicked = true;
204
- console.log(chalk.green('✅ 点击了连接按钮'));
205
- break;
192
+ // 直接使用 evaluate 在 iframe 中执行点击
193
+ // 这样可以绑过任何遮挡问题
194
+ try {
195
+ clicked = await frame.evaluate(() => {
196
+ const btn = document.querySelector('button[title="Connect WebSocket Proxy"]');
197
+ if (btn) {
198
+ // 使用 dispatchEvent 触发真实的点击事件
199
+ const clickEvent = new MouseEvent('click', {
200
+ bubbles: true,
201
+ cancelable: true,
202
+ view: window
203
+ });
204
+ btn.dispatchEvent(clickEvent);
205
+ return true;
206
206
  }
207
+ return false;
208
+ });
209
+ if (clicked) {
210
+ console.log(chalk.green('✅ 点击了连接按钮'));
207
211
  }
208
- catch (btnErr) {
209
- console.log(chalk.gray(` 点击失败: ${btnErr}`));
210
- }
211
212
  }
212
- // 如果遍历没找到,尝试 evaluate 直接执行点击
213
+ catch (e) {
214
+ console.log(chalk.gray(`evaluate 点击失败: ${e}`));
215
+ }
216
+ // 如果 dispatchEvent 失败,尝试直接调用 onclick
213
217
  if (!clicked) {
214
218
  try {
215
219
  clicked = await frame.evaluate(() => {
@@ -221,11 +225,11 @@ export class BrowserManager {
221
225
  return false;
222
226
  });
223
227
  if (clicked) {
224
- console.log(chalk.green('✅ 点击了连接按钮 (evaluate)'));
228
+ console.log(chalk.green('✅ 点击了连接按钮 (click())'));
225
229
  }
226
230
  }
227
231
  catch (e) {
228
- console.log(chalk.gray(`evaluate 点击失败: ${e}`));
232
+ console.log(chalk.gray(`click() 失败: ${e}`));
229
233
  }
230
234
  }
231
235
  }
@@ -241,7 +245,7 @@ export class BrowserManager {
241
245
  // 第四步:等待并验证连接成功(按钮文字变成 "Disconnect WS")
242
246
  console.log(chalk.gray('等待 WebSocket 连接...'));
243
247
  let connected = false;
244
- for (let i = 0; i < 10; i++) { // 最多等待 10
248
+ for (let i = 0; i < 15; i++) { // 最多等待 15
245
249
  await sleep(1000);
246
250
  if (buildAppFrame) {
247
251
  try {
@@ -249,6 +253,7 @@ export class BrowserManager {
249
253
  const btn = document.querySelector('button[title="Connect WebSocket Proxy"], button[title="Disconnect WebSocket Proxy"]');
250
254
  return btn?.textContent?.trim() || '';
251
255
  });
256
+ console.log(chalk.gray(` 检测按钮文字: "${buttonText}"`));
252
257
  if (buttonText.includes('Disconnect')) {
253
258
  connected = true;
254
259
  console.log(chalk.green('✅ WebSocket 连接成功!'));
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ const program = new Command();
12
12
  program
13
13
  .name('gemini-client')
14
14
  .description('Gemini Proxy Build App 客户端 - 使用 Camoufox 自动保持连接')
15
- .version('1.0.10');
15
+ .version('1.0.11');
16
16
  program
17
17
  .command('start')
18
18
  .description('启动客户端,连接到代理服务器')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-proxy-client",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Gemini Proxy Build App 客户端 - 使用 Camoufox 自动保持连接",
5
5
  "main": "dist/index.js",
6
6
  "bin": {