cdp-tunnel 2.2.0 → 2.2.2

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.
@@ -158,10 +158,10 @@ importScripts('features/automation-badge.js');
158
158
  }
159
159
 
160
160
  var openerTabId = tab.openerTabId;
161
- var isOpenerControlled = openerTabId && State.isTabAttached(openerTabId);
161
+ var isOpenerControlled = openerTabId && State.isTabAttached(openerTabId) && !State.isPreExistingTab(openerTabId);
162
162
 
163
- // 只有当 opener CDP 控制时才跟踪新页面
164
- // 这样可以避免跟踪用户手动点击链接打开的页面
163
+ // 只有当 opener CDP 主动管理的 tab 时才跟踪新页面
164
+ // pre-existing tab 虽然也 attach 了 debugger,但属于用户 tab,不应继承 CDP 控制
165
165
  if (!openerTabId) {
166
166
  Logger.info('[Tabs] Tab has no opener, skipping. tabId:', tabId);
167
167
  return;
@@ -440,8 +440,6 @@ function checkTabVisibility(tabId) {
440
440
  var sessionId = CDPUtils.generateSessionId();
441
441
  State.mapSession(sessionId, tabId, targetId);
442
442
 
443
- addTabToAutomationGroup(tabId);
444
-
445
443
  var config = State.getAutoAttachConfig();
446
444
  if (config.waitForDebuggerOnStart) {
447
445
  State.addPendingDebuggerTab(tabId);
@@ -316,7 +316,6 @@ var WebSocketManager = (function() {
316
316
 
317
317
  function closeTabsByClientId(clientId, resolve) {
318
318
  var attachedTabs = State.getAttachedTabIds();
319
- var groupId = State.getGroupIdForClient(clientId);
320
319
  var tabsToClose = [];
321
320
 
322
321
  attachedTabs.forEach(function(tabId) {
@@ -331,25 +330,7 @@ var WebSocketManager = (function() {
331
330
  return;
332
331
  }
333
332
 
334
- if (groupId) {
335
- chrome.tabs.query({ groupId: groupId }, function(groupTabs) {
336
- if (chrome.runtime.lastError || !groupTabs) {
337
- resolve();
338
- return;
339
- }
340
- var groupTabIds = new Set(groupTabs.map(function(t) { return t.id; }));
341
- var safeToClose = tabsToClose.filter(function(tabId) {
342
- return groupTabIds.has(tabId);
343
- });
344
- var unsafeCount = tabsToClose.length - safeToClose.length;
345
- if (unsafeCount > 0) {
346
- Logger.info('[WS] Protecting ' + unsafeCount + ' tabs outside group from deletion');
347
- }
348
- doCloseTabs(safeToClose, clientId, resolve);
349
- });
350
- } else {
351
- doCloseTabs(tabsToClose, clientId, resolve);
352
- }
333
+ doCloseTabs(tabsToClose, clientId, resolve);
353
334
  }
354
335
 
355
336
  function doCloseTabs(tabIds, clientId, resolve) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.0.0",
4
+ "version": "2.2.2",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
@@ -33,8 +33,13 @@
33
33
  },
34
34
  "web_accessible_resources": [
35
35
  {
36
- "resources": ["config-page-preview.html", "config-page.js"],
37
- "matches": ["<all_urls>"]
36
+ "resources": [
37
+ "config-page-preview.html",
38
+ "config-page.js"
39
+ ],
40
+ "matches": [
41
+ "<all_urls>"
42
+ ]
38
43
  }
39
44
  ]
40
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
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",
@@ -672,16 +672,6 @@ function handlePluginConnection(ws, clientInfo) {
672
672
  totalClients: clientConnections.size
673
673
  });
674
674
 
675
- logDisconnect('PLUGIN_DISCONNECTED', {
676
- pluginId: id,
677
- code, reason: reason?.toString() || 'none',
678
- remainingPlugins: pluginConnections.size,
679
- affectedClients: affectedClients.map(c => c),
680
- uptime: ws.connectedAt ? `${((Date.now() - ws.connectedAt) / 1000).toFixed(0)}s` : 'unknown',
681
- activeSessions: sessionToClientId.size,
682
- pendingRequests: pendingAttachRequests.size
683
- });
684
-
685
675
  if (pluginConnections.size === 0) {
686
676
  updateExtensionState(false);
687
677
  }
@@ -709,6 +699,16 @@ function handlePluginConnection(ws, clientInfo) {
709
699
  }
710
700
  });
711
701
 
702
+ logDisconnect('PLUGIN_DISCONNECTED', {
703
+ pluginId: id,
704
+ code, reason: reason?.toString() || 'none',
705
+ remainingPlugins: pluginConnections.size,
706
+ affectedClients,
707
+ uptime: ws.connectedAt ? `${((Date.now() - ws.connectedAt) / 1000).toFixed(0)}s` : 'unknown',
708
+ activeSessions: sessionToClientId.size,
709
+ pendingRequests: pendingAttachRequests.size
710
+ });
711
+
712
712
  if (affectedClients.length > 0) {
713
713
  logConnectionEvent('PLUGIN_DISCONNECT_AFFECTED_CLIENTS', { pluginId: id, affectedClients });
714
714
  }