cdp-tunnel 2.9.0 → 2.9.1

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.
@@ -466,14 +466,14 @@ importScripts('features/automation-badge.js');
466
466
  status = 'error';
467
467
  }
468
468
  }
469
- return { id: conn.id, tag: conn.tag, url: conn.url, status: status, attachedCount: attachedCount };
469
+ return { id: conn.id, tag: conn.tag, url: conn.url, mode: conn.mode || 'create', status: status, attachedCount: attachedCount };
470
470
  });
471
471
  sendResponse({ connections: list });
472
472
  });
473
473
  return true;
474
474
  } else if (message.type === 'add-connection') {
475
- Logger.info('[Runtime] Adding connection:', message.tag, message.url);
476
- Config.addConnection({ tag: message.tag, url: message.url }, function(conn) {
475
+ Logger.info('[Runtime] Adding connection:', message.tag, message.url, 'mode:', message.mode);
476
+ Config.addConnection({ tag: message.tag, url: message.url, mode: message.mode || 'create' }, function(conn) {
477
477
  if (conn && conn.enabled) {
478
478
  ConnectionManager.addConnection(conn);
479
479
  var entry = ConnectionManager.getConnection(conn.id);
@@ -814,6 +814,10 @@
814
814
  <div class="add-conn-form">
815
815
  <input type="text" class="input-tag" id="newConnTag" placeholder="名称" value="local">
816
816
  <input type="text" class="input-url" id="newConnUrl" placeholder="ws://localhost:9221/plugin" value="ws://localhost:9221/plugin">
817
+ <select id="inputMode" style="padding:8px 10px;border:1px solid #d1d5db;border-radius:6px;font-size:13px;outline:none;transition:border-color 0.2s;flex-shrink:0;">
818
+ <option value="create">创建模式</option>
819
+ <option value="takeover">接管模式</option>
820
+ </select>
817
821
  <button class="btn btn-primary btn-sm" id="addConnBtn">添加连接</button>
818
822
  </div>
819
823
  </div>
@@ -27,6 +27,7 @@
27
27
  newConnTag: document.getElementById('newConnTag'),
28
28
  newConnUrl: document.getElementById('newConnUrl'),
29
29
  addConnBtn: document.getElementById('addConnBtn'),
30
+ inputMode: document.getElementById('inputMode'),
30
31
  autoMuteToggle: document.getElementById('autoMuteToggle'),
31
32
  pluginIdDisplay: document.getElementById('pluginIdDisplay')
32
33
  };
@@ -99,7 +100,7 @@
99
100
  '<input type="checkbox" class="conn-toggle" data-id="' + conn.id + '"' + (conn.enabled ? ' checked' : '') + ' title="启用/禁用">' +
100
101
  '<span class="status-dot ' + statusClass + '" title="' + statusClass + '"></span>' +
101
102
  '<div class="conn-config-info">' +
102
- '<div class="conn-config-tag">' + escapeHtml(conn.tag) + '</div>' +
103
+ '<div class="conn-config-tag">' + (conn.mode === 'takeover' ? '🔗 ' : '🆕 ') + escapeHtml(conn.tag) + '</div>' +
103
104
  '<div class="conn-config-url" title="' + escapeAttr(conn.url) + '">' + escapeHtml(conn.url) + '</div>' +
104
105
  '</div>' +
105
106
  '<button class="btn-delete" data-id="' + conn.id + '" title="删除">删除</button>' +
@@ -333,6 +334,7 @@
333
334
  elements.addConnBtn.addEventListener('click', function() {
334
335
  var tag = elements.newConnTag.value.trim();
335
336
  var url = elements.newConnUrl.value.trim();
337
+ var mode = elements.inputMode.value || 'create';
336
338
 
337
339
  if (!tag) {
338
340
  showToast('请输入连接名称', 'error');
@@ -344,16 +346,18 @@
344
346
  }
345
347
 
346
348
  if (typeof chrome !== 'undefined' && chrome.runtime) {
347
- chrome.runtime.sendMessage({ type: 'add-connection', tag: tag, url: url }, function() {
349
+ chrome.runtime.sendMessage({ type: 'add-connection', tag: tag, url: url, mode: mode }, function() {
348
350
  elements.newConnTag.value = '';
349
351
  elements.newConnUrl.value = '';
352
+ elements.inputMode.value = 'create';
350
353
  loadAndRenderConnections();
351
354
  showToast('连接已添加');
352
355
  });
353
356
  } else if (typeof Config !== 'undefined') {
354
- Config.addConnection({ tag: tag, url: url }, function() {
357
+ Config.addConnection({ tag: tag, url: url, mode: mode }, function() {
355
358
  elements.newConnTag.value = '';
356
359
  elements.newConnUrl.value = '';
360
+ elements.inputMode.value = 'create';
357
361
  loadAndRenderConnections();
358
362
  showToast('连接已添加');
359
363
  });
@@ -23,7 +23,7 @@ var ConnectionManager = (function() {
23
23
  return;
24
24
  }
25
25
 
26
- var state = new ConnectionState(config.id);
26
+ var state = new ConnectionState(config.id, config.mode);
27
27
  var wsManager = new WebSocketConnection(config.id, state, config);
28
28
 
29
29
  _connections.set(config.id, {
@@ -1,5 +1,6 @@
1
- function ConnectionState(connectionId) {
1
+ function ConnectionState(connectionId, mode) {
2
2
  this.connectionId = connectionId;
3
+ this.mode = mode || 'create';
3
4
  this.ws = null;
4
5
  this.reconnectTimer = null;
5
6
  this._hasConnectedClient = false;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.9.0",
4
+ "version": "2.9.1",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
@@ -32,9 +32,11 @@
32
32
  var dot = document.createElement('span');
33
33
  dot.className = 'conn-dot ' + conn.status;
34
34
 
35
+ var modeIcon = conn.mode === 'takeover' ? '🔗 ' : '🆕 ';
36
+
35
37
  var tag = document.createElement('span');
36
38
  tag.className = 'conn-tag';
37
- tag.textContent = conn.tag;
39
+ tag.textContent = modeIcon + conn.tag;
38
40
 
39
41
  header.appendChild(dot);
40
42
  header.appendChild(tag);
@@ -58,6 +58,7 @@ var Config = {
58
58
  id: 'conn_' + Date.now() + '_' + Math.random().toString(36).substr(2, 6),
59
59
  tag: opts.tag || 'unnamed',
60
60
  url: opts.url || '',
61
+ mode: opts.mode || 'create',
61
62
  enabled: opts.enabled !== undefined ? opts.enabled : true
62
63
  };
63
64
  connections.push(conn);
@@ -91,6 +92,7 @@ var Config = {
91
92
  if (c.id === id) {
92
93
  if (updates.tag !== undefined) c.tag = updates.tag;
93
94
  if (updates.url !== undefined) c.url = updates.url;
95
+ if (updates.mode !== undefined) c.mode = updates.mode;
94
96
  }
95
97
  });
96
98
  Config.setConnections(connections, callback);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "2.9.0",
3
+ "version": "2.9.1",
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",