cdp-tunnel 2.5.2 → 2.5.3

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.
@@ -135,6 +135,19 @@ var LocalHandler = (function() {
135
135
  return {};
136
136
  }
137
137
 
138
+ function tabGetGroupInfo(context) {
139
+ var clientId = context.clientId;
140
+ var groupId = null;
141
+ var baseName = null;
142
+ try {
143
+ groupId = State.getGroupIdForClient(clientId);
144
+ baseName = CDPUtils.getGroupBaseName(clientId);
145
+ } catch (e) {
146
+ Logger.error('[TabGetGroupInfo] Error: ' + (e.message || e));
147
+ }
148
+ return Promise.resolve({ groupId: groupId, baseName: baseName, clientId: clientId });
149
+ }
150
+
138
151
  function tabGetMuteStatus(params) {
139
152
  var cdpOnly = params && params.cdpOnly;
140
153
  var attachedTabIds = State.getAttachedTabIds();
@@ -308,6 +321,7 @@ var LocalHandler = (function() {
308
321
  getTargetInfos: getTargetInfos,
309
322
  getTargetInfoById: getTargetInfoById,
310
323
  mapToTargetInfo: mapToTargetInfo,
311
- tabGetMuteStatus: tabGetMuteStatus
324
+ tabGetMuteStatus: tabGetMuteStatus,
325
+ tabGetGroupInfo: tabGetGroupInfo
312
326
  };
313
327
  })();
@@ -142,47 +142,68 @@ var SpecialHandler = (function() {
142
142
  return;
143
143
  }
144
144
  var baseName = CDPUtils.getGroupBaseName(groupClientId);
145
-
146
- setTimeout(function() {
147
- Logger.info('[TabGroup] Executing group operation for:', baseName);
148
-
149
- chrome.tabGroups.query({}, function(allGroups) {
150
- var existing = CDPUtils.findGroupByName(allGroups, baseName);
151
- if (existing) {
152
- chrome.tabs.group({ tabIds: tabId, groupId: existing.id }, function(result) {
153
- if (chrome.runtime.lastError) {
154
- Logger.error('[TabGroup] Failed to add tab to group:', chrome.runtime.lastError.message);
155
- } else {
156
- State.setGroupIdForClient(groupClientId, existing.id);
157
- updateTabGroupName(groupClientId);
158
- Logger.info('[TabGroup] Tab', tabId, 'added to existing group:', existing.id);
159
- }
160
- });
145
+
146
+ var retries = 0;
147
+ var maxRetries = 20;
148
+ function tryGroup() {
149
+ chrome.tabs.get(tabId, function(tab) {
150
+ if (chrome.runtime.lastError || !tab) {
151
+ Logger.error('[TabGroup] Tab not found:', tabId, 'retries:', retries);
152
+ return;
153
+ }
154
+ if (tab.status === 'complete') {
155
+ Logger.info('[TabGroup] Tab ready, executing group operation for:', baseName);
156
+ doGroup(tabId, groupClientId, baseName);
157
+ } else if (retries < maxRetries) {
158
+ retries++;
159
+ Logger.info('[TabGroup] Tab not ready (', tab.status, '), retry', retries, '/', maxRetries);
160
+ setTimeout(tryGroup, 200);
161
161
  } else {
162
- chrome.tabs.group({ tabIds: tabId }, function(groupId) {
163
- if (chrome.runtime.lastError) {
164
- Logger.error('[TabGroup] Failed to create group:', chrome.runtime.lastError.message);
165
- return;
166
- }
167
- if (groupId) {
168
- chrome.tabGroups.update(groupId, {
169
- title: baseName,
170
- color: CDPUtils.getGroupColorForClient(groupClientId),
171
- collapsed: true
172
- }, function() {
173
- if (chrome.runtime.lastError) {
174
- Logger.error('[TabGroup] Failed to update group:', chrome.runtime.lastError.message);
175
- } else {
176
- State.setGroupIdForClient(groupClientId, groupId);
177
- updateTabGroupName(groupClientId);
178
- Logger.info('[TabGroup] Created new group:', groupId, 'with tab:', tabId);
179
- }
180
- });
181
- }
182
- });
162
+ Logger.warn('[TabGroup] Tab never reached complete status, grouping anyway. tabId:', tabId);
163
+ doGroup(tabId, groupClientId, baseName);
183
164
  }
184
165
  });
185
- }, 500);
166
+ }
167
+ tryGroup();
168
+ }
169
+
170
+ function doGroup(tabId, clientId, baseName) {
171
+ chrome.tabGroups.query({}, function(allGroups) {
172
+ var existing = CDPUtils.findGroupByName(allGroups, baseName);
173
+ if (existing) {
174
+ chrome.tabs.group({ tabIds: tabId, groupId: existing.id }, function(result) {
175
+ if (chrome.runtime.lastError) {
176
+ Logger.error('[TabGroup] Failed to add tab to group:', chrome.runtime.lastError.message);
177
+ } else {
178
+ State.setGroupIdForClient(clientId, existing.id);
179
+ updateTabGroupName(clientId);
180
+ Logger.info('[TabGroup] Tab', tabId, 'added to existing group:', existing.id);
181
+ }
182
+ });
183
+ } else {
184
+ chrome.tabs.group({ tabIds: tabId }, function(groupId) {
185
+ if (chrome.runtime.lastError) {
186
+ Logger.error('[TabGroup] Failed to create group:', chrome.runtime.lastError.message);
187
+ return;
188
+ }
189
+ if (groupId) {
190
+ chrome.tabGroups.update(groupId, {
191
+ title: baseName,
192
+ color: CDPUtils.getGroupColorForClient(clientId),
193
+ collapsed: true
194
+ }, function() {
195
+ if (chrome.runtime.lastError) {
196
+ Logger.error('[TabGroup] Failed to update group:', chrome.runtime.lastError.message);
197
+ } else {
198
+ State.setGroupIdForClient(clientId, groupId);
199
+ updateTabGroupName(clientId);
200
+ Logger.info('[TabGroup] Created new group:', groupId, 'with tab:', tabId);
201
+ }
202
+ });
203
+ }
204
+ });
205
+ }
206
+ });
186
207
  }
187
208
 
188
209
  function updateTabGroupName(clientId) {
@@ -23,6 +23,7 @@ var CDP_HANDLERS = {
23
23
  'Target.attachToBrowserTarget': { type: 'LOCAL', handler: LocalHandler.targetAttachToBrowserTarget },
24
24
 
25
25
  'Tab.getMuteStatus': { type: 'LOCAL', handler: LocalHandler.tabGetMuteStatus },
26
+ 'Tab.getGroupInfo': { type: 'LOCAL', handler: LocalHandler.tabGetGroupInfo },
26
27
 
27
28
  'SystemInfo.getInfo': { type: 'LOCAL', handler: LocalHandler.systemInfoGetInfo },
28
29
  'SystemInfo.getProcessInfo': { type: 'LOCAL', handler: LocalHandler.systemInfoGetProcessInfo },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "CDP Bridge",
4
- "version": "2.5.2",
4
+ "version": "2.5.3",
5
5
  "description": "Chrome DevTools Protocol Bridge for Playwright/Puppeteer automation",
6
6
  "permissions": [
7
7
  "debugger",
@@ -1,5 +1,5 @@
1
1
  var Config = {
2
- WS_URL: 'ws://localhost:43930/plugin',
2
+ WS_URL: 'ws://localhost:25429/plugin',
3
3
  RECONNECT_DELAY: 3000,
4
4
  DEBUGGER_VERSION: '1.3',
5
5
  HEARTBEAT_INTERVAL: 25000,
@@ -44,7 +44,8 @@ var CDPUtils = (function() {
44
44
 
45
45
  function buildGroupName(clientId) {
46
46
  if (!clientId) return 'CDP';
47
- return 'CDP-' + clientId.substring(0, 8);
47
+ var suffix = clientId.length > 8 ? clientId.substring(clientId.length - 8) : clientId;
48
+ return 'CDP-' + suffix;
48
49
  }
49
50
 
50
51
  function getGroupBaseName(clientId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
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",