cdp-tunnel 2.10.7 → 2.10.9

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.
package/README.md CHANGED
@@ -55,45 +55,40 @@
55
55
 
56
56
  ## Quick Start
57
57
 
58
- ### Option 1: Install via npm (Recommended)
58
+ ### Option 1: Install Extension Only (No npm needed)
59
59
 
60
- ```bash
61
- # Install globally
62
- npm install -g cdp-tunnel
63
-
64
- # Start server
65
- cdp-tunnel start
60
+ Download and install the Chrome extension directly:
66
61
 
67
- # Check status
68
- cdp-tunnel status
69
-
70
- # Install Chrome extension (opens interactive guide)
71
- cdp-tunnel extension
72
- ```
62
+ 1. Download [`cdp-tunnel-extension.zip`](https://github.com/dyyz1993/cdp-tunnel/releases/latest/download/cdp-tunnel-extension.zip) from the latest release
63
+ 2. Unzip it
64
+ 3. Open `chrome://extensions/` in Chrome
65
+ 4. Enable **Developer mode** (top right)
66
+ 5. Click **Load unpacked** → select the unzipped folder
67
+ 6. Start the proxy server separately (see Option 2 or 3 below)
73
68
 
74
- ### Option 2: Download Extension from GitHub Releases
69
+ ### Option 2: Install via npm (Recommended)
75
70
 
76
- **Download Extension:** [cdp-tunnel-extension.zip (v2.10.3)](https://github.com/dyyz1993/cdp-tunnel/releases/tag/v2.10.3)
71
+ ```bash
72
+ # One command to set up everything
73
+ npx cdp-tunnel setup
77
74
 
78
- 1. Download `cdp-tunnel-extension.zip` from the latest [GitHub Releases](https://github.com/dyyz1993/cdp-tunnel/releases)
79
- 2. Unzip the file
80
- 3. Open `chrome://extensions/` in Chrome
81
- 4. Enable "Developer mode"
82
- 5. Click "Load unpacked"
83
- 6. Select the unzipped extension directory
75
+ # Or install globally
76
+ npm install -g cdp-tunnel
77
+ cdp-tunnel setup # Start server + auto-load extension into Chrome
78
+ cdp-tunnel status # Check status
79
+ cdp-tunnel diagnose # Diagnose connection issues
80
+ ```
84
81
 
85
82
  ### Option 3: Manual Installation
86
83
 
87
84
  #### 1. Start the Proxy Server
88
85
 
89
86
  ```bash
90
- cd server
91
- npm install
92
- node proxy-server.js
87
+ npx cdp-tunnel start
88
+ # or manually:
89
+ npx cdp-tunnel start -p 9221
93
90
  ```
94
91
 
95
- The server will start on `localhost:9221`.
96
-
97
92
  #### 2. Install Chrome Extension
98
93
 
99
94
  1. Open `chrome://extensions/`
package/cli/index.js CHANGED
@@ -906,16 +906,106 @@ program.addHelpText('after', `
906
906
  $ cdp-tunnel start 启动服务(自动启动 Chrome)
907
907
  $ cdp-tunnel start --auto-restart Chrome 断连时自动重启
908
908
  $ cdp-tunnel start --watchdog 服务崩溃时自动重启
909
+ $ cdp-tunnel setup 一键安装:启动服务 + 加载扩展
909
910
  $ cdp-tunnel status 查看状态
910
911
  $ cdp-tunnel update 检查并更新
911
912
  $ cdp-tunnel diagnose 诊断连接问题
912
913
  $ cdp-tunnel extension 安装 Chrome 扩展
913
914
 
914
915
  快速开始:
915
- $ npm install -g cdp-tunnel
916
- $ cdp-tunnel start # 一行命令搞定!
916
+ $ npx cdp-tunnel setup # 无需全局安装,一键搞定!
917
917
  `);
918
918
 
919
+ program
920
+ .command('setup')
921
+ .description('一键安装:启动服务器 + 自动加载 Chrome 扩展')
922
+ .option('-p, --port <port>', '指定端口', parseInt)
923
+ .action(async (options) => {
924
+ const globalConfig = getConfig();
925
+ const port = options.port || globalConfig.port || 9221;
926
+ const instanceConfig = getConfig(port);
927
+ instanceConfig.port = port;
928
+ saveConfig(instanceConfig, port);
929
+
930
+ console.log('');
931
+ log('bold', 'CDP Tunnel 一键安装');
932
+ console.log('');
933
+
934
+ if (isServerRunning(port)) {
935
+ log('green', ` Proxy: 已运行 (端口 ${port})`);
936
+ } else {
937
+ ensureInstanceDir(port);
938
+ startServer(port, false, false);
939
+ log('green', ` Proxy: 已启动 (端口 ${port})`);
940
+ }
941
+
942
+ await new Promise(r => setTimeout(r, 1000));
943
+
944
+ const extStatus = checkChromeExtension(port);
945
+ if (extStatus.connected) {
946
+ log('green', ' 扩展: 已连接');
947
+ console.log('');
948
+ log('green', ' Ready!');
949
+ log('cyan', ` CDP: http://localhost:${port}`);
950
+ process.exit(0);
951
+ return;
952
+ }
953
+
954
+ const { isChromeRunning, launchChromeWithExtension } = require('./chrome-manager');
955
+ const chromeRunning = isChromeRunning();
956
+
957
+ if (!chromeRunning) {
958
+ log('cyan', ' Chrome: 启动中 (带扩展)...');
959
+ const launched = launchChromeWithExtension();
960
+ if (launched) {
961
+ const connected = await waitForPluginConnection(port, 15000);
962
+ if (connected) {
963
+ log('green', ' 扩展: 已连接');
964
+ } else {
965
+ log('yellow', ' 扩展: 请点击 Chrome 工具栏上的 CDP Bridge 图标');
966
+ }
967
+ } else {
968
+ log('yellow', ' Chrome: 无法自动启动');
969
+ log('cyan', ' 请手动安装扩展:');
970
+ console.log('');
971
+ log('gray', ' 1. 打开 chrome://extensions/');
972
+ log('gray', ' 2. 开启开发者模式');
973
+ log('gray', ` 3. 加载: ${getExtensionPath()}`);
974
+ const connected = await waitForPluginConnection(port, 120000);
975
+ if (connected) {
976
+ log('green', ' 扩展: 已连接');
977
+ } else {
978
+ log('yellow', ' 超时,请稍后运行: cdp-tunnel start');
979
+ process.exit(1);
980
+ }
981
+ }
982
+ } else {
983
+ log('yellow', ' Chrome: 已运行,需要加载扩展');
984
+ log('cyan', ' 正在打开引导...');
985
+
986
+ const guidePath = generateGuideHtml();
987
+ const platform = os.platform();
988
+ try {
989
+ if (platform === 'darwin') execSync('open "' + guidePath + '"');
990
+ else if (platform === 'win32') execSync('start "" "' + guidePath + '"');
991
+ else execSync('xdg-open "' + guidePath + '"');
992
+ } catch {}
993
+
994
+ const connected = await waitForPluginConnection(port, 120000);
995
+ if (connected) {
996
+ log('green', ' 扩展: 已连接');
997
+ } else {
998
+ log('yellow', ' 超时,请稍后运行: cdp-tunnel start');
999
+ process.exit(1);
1000
+ }
1001
+ }
1002
+
1003
+ console.log('');
1004
+ log('green', ' Ready!');
1005
+ log('cyan', ` CDP: http://localhost:${port}`);
1006
+ process.exit(0);
1007
+ });
1008
+
919
1009
  ensureConfigDir();
920
1010
  migrateFromLegacy();
921
1011
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.10.7",
4
+ "version": "2.10.9",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "2.10.7",
3
+ "version": "2.10.9",
4
4
  "description": "Bridge Chrome's debugger API to WebSocket — control your existing browser with Playwright/Puppeteer via CDP",
5
5
  "main": "server/proxy-server.js",
6
6
  "bin": "./cli/index.js",