cdp-tunnel 2.5.12 → 2.5.13
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.
|
@@ -230,56 +230,7 @@ importScripts('features/automation-badge.js');
|
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
setTimeout(function() {
|
|
235
|
-
var openerClientId = openerTabId ? State.getClientIdByTabId(openerTabId) : null;
|
|
236
|
-
var groupClientId = openerClientId;
|
|
237
|
-
if (!groupClientId) {
|
|
238
|
-
var cdpClients = State.getCDPClients() || [];
|
|
239
|
-
if (cdpClients.length > 0 && cdpClients[0] && cdpClients[0].id) {
|
|
240
|
-
groupClientId = cdpClients[0].id;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (!groupClientId) return;
|
|
245
|
-
var baseName = CDPUtils.getGroupBaseName(groupClientId);
|
|
246
|
-
Logger.info('[TabGroup] background onCreated, baseName:', baseName);
|
|
247
|
-
|
|
248
|
-
chrome.tabGroups.query({}, function(allGroups) {
|
|
249
|
-
var existing = CDPUtils.findGroupByName(allGroups, baseName);
|
|
250
|
-
if (existing) {
|
|
251
|
-
chrome.tabs.group({ tabIds: tabId, groupId: existing.id }, function(groupId) {
|
|
252
|
-
if (chrome.runtime.lastError) {
|
|
253
|
-
Logger.error('[TabGroup] Failed to add tab to group:', chrome.runtime.lastError.message);
|
|
254
|
-
} else {
|
|
255
|
-
State.setGroupIdForClient(groupClientId, existing.id);
|
|
256
|
-
Logger.info('[TabGroup] Tab added to group:', groupId);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
} else {
|
|
260
|
-
chrome.tabs.group({ tabIds: tabId }, function(groupId) {
|
|
261
|
-
if (chrome.runtime.lastError) {
|
|
262
|
-
Logger.error('[TabGroup] Failed to create group:', chrome.runtime.lastError.message);
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
if (groupId) {
|
|
266
|
-
chrome.tabGroups.update(groupId, {
|
|
267
|
-
title: baseName,
|
|
268
|
-
color: CDPUtils.getGroupColorForClient(groupClientId),
|
|
269
|
-
collapsed: true
|
|
270
|
-
}, function(group) {
|
|
271
|
-
if (chrome.runtime.lastError) {
|
|
272
|
-
Logger.error('[TabGroup] Failed to update group:', chrome.runtime.lastError.message);
|
|
273
|
-
} else {
|
|
274
|
-
State.setGroupIdForClient(groupClientId, groupId);
|
|
275
|
-
Logger.info('[TabGroup] Group created:', group);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}, 2000);
|
|
233
|
+
SpecialHandler.addTabToAutomationGroup(tabId, openerClientId);
|
|
283
234
|
|
|
284
235
|
Logger.info('[Tabs] Sending Target.attachedToTarget event');
|
|
285
236
|
|
|
@@ -135,17 +135,96 @@ var LocalHandler = (function() {
|
|
|
135
135
|
return {};
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
function
|
|
138
|
+
function tabUngroup(context) {
|
|
139
139
|
var clientId = context.clientId;
|
|
140
140
|
var groupId = null;
|
|
141
|
-
var baseName = null;
|
|
142
141
|
try {
|
|
143
142
|
groupId = State.getGroupIdForClient(clientId);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
Logger.error('[TabUngroup] Error getting groupId: ' + (e.message || e));
|
|
145
|
+
return Promise.resolve({ success: false, ungroupedCount: 0, error: e.message || String(e) });
|
|
146
|
+
}
|
|
147
|
+
if (groupId == null) {
|
|
148
|
+
return Promise.resolve({ success: true, ungroupedCount: 0 });
|
|
149
|
+
}
|
|
150
|
+
return new Promise(function(resolve) {
|
|
151
|
+
chrome.tabs.query({ groupId: groupId }, function(tabs) {
|
|
152
|
+
if (chrome.runtime.lastError) {
|
|
153
|
+
Logger.error('[TabUngroup] chrome.runtime.lastError: ' + chrome.runtime.lastError.message);
|
|
154
|
+
resolve({ success: false, ungroupedCount: 0, error: chrome.runtime.lastError.message });
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!tabs || tabs.length === 0) {
|
|
158
|
+
resolve({ success: true, ungroupedCount: 0 });
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
var tabIds = tabs.map(function(tab) { return tab.id; });
|
|
162
|
+
chrome.tabs.ungroup(tabIds, function() {
|
|
163
|
+
if (chrome.runtime.lastError) {
|
|
164
|
+
Logger.error('[TabUngroup] ungroup lastError: ' + chrome.runtime.lastError.message);
|
|
165
|
+
resolve({ success: false, ungroupedCount: 0, error: chrome.runtime.lastError.message });
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
State.removeGroupForClient(clientId);
|
|
169
|
+
resolve({ success: true, ungroupedCount: tabIds.length });
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function tabGetGroupInfo(context) {
|
|
176
|
+
var clientId = context.clientId;
|
|
177
|
+
var cachedGroupId = null;
|
|
178
|
+
var baseName = null;
|
|
179
|
+
try {
|
|
180
|
+
cachedGroupId = State.getGroupIdForClient(clientId);
|
|
144
181
|
baseName = CDPUtils.getGroupBaseName(clientId);
|
|
145
182
|
} catch (e) {
|
|
146
183
|
Logger.error('[TabGetGroupInfo] Error: ' + (e.message || e));
|
|
147
184
|
}
|
|
148
|
-
|
|
185
|
+
|
|
186
|
+
var attachedTabIds = State.getAttachedTabIds();
|
|
187
|
+
var matchedTabId = null;
|
|
188
|
+
for (var i = 0; i < attachedTabIds.length; i++) {
|
|
189
|
+
if (State.getClientIdByTabId(attachedTabIds[i]) === clientId) {
|
|
190
|
+
matchedTabId = attachedTabIds[i];
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (matchedTabId == null) {
|
|
196
|
+
return Promise.resolve({
|
|
197
|
+
groupId: -1,
|
|
198
|
+
cachedGroupId: cachedGroupId,
|
|
199
|
+
baseName: baseName,
|
|
200
|
+
clientId: clientId,
|
|
201
|
+
tabId: null
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var tabId = matchedTabId;
|
|
206
|
+
return new Promise(function(resolve) {
|
|
207
|
+
chrome.tabs.get(tabId, function(tab) {
|
|
208
|
+
if (chrome.runtime.lastError) {
|
|
209
|
+
Logger.error('[TabGetGroupInfo] chrome.tabs.get error: ' + chrome.runtime.lastError.message);
|
|
210
|
+
resolve({
|
|
211
|
+
groupId: -1,
|
|
212
|
+
cachedGroupId: cachedGroupId,
|
|
213
|
+
baseName: baseName,
|
|
214
|
+
clientId: clientId,
|
|
215
|
+
tabId: tabId
|
|
216
|
+
});
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
resolve({
|
|
220
|
+
groupId: tab.groupId != null ? tab.groupId : -1,
|
|
221
|
+
cachedGroupId: cachedGroupId,
|
|
222
|
+
baseName: baseName,
|
|
223
|
+
clientId: clientId,
|
|
224
|
+
tabId: tabId
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
149
228
|
}
|
|
150
229
|
|
|
151
230
|
function tabGetMuteStatus(params) {
|
|
@@ -322,6 +401,7 @@ var LocalHandler = (function() {
|
|
|
322
401
|
getTargetInfoById: getTargetInfoById,
|
|
323
402
|
mapToTargetInfo: mapToTargetInfo,
|
|
324
403
|
tabGetMuteStatus: tabGetMuteStatus,
|
|
325
|
-
tabGetGroupInfo: tabGetGroupInfo
|
|
404
|
+
tabGetGroupInfo: tabGetGroupInfo,
|
|
405
|
+
tabUngroup: tabUngroup
|
|
326
406
|
};
|
|
327
407
|
})();
|
|
@@ -149,28 +149,8 @@ var SpecialHandler = (function() {
|
|
|
149
149
|
}
|
|
150
150
|
var baseName = CDPUtils.getGroupBaseName(groupClientId);
|
|
151
151
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
function tryGroup() {
|
|
155
|
-
chrome.tabs.get(tabId, function(tab) {
|
|
156
|
-
if (chrome.runtime.lastError || !tab) {
|
|
157
|
-
Logger.error('[TabGroup] Tab not found:', tabId, 'retries:', retries);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (tab.status === 'complete') {
|
|
161
|
-
Logger.info('[TabGroup] Tab ready, executing group operation for:', baseName);
|
|
162
|
-
doGroup(tabId, groupClientId, baseName);
|
|
163
|
-
} else if (retries < maxRetries) {
|
|
164
|
-
retries++;
|
|
165
|
-
Logger.info('[TabGroup] Tab not ready (', tab.status, '), retry', retries, '/', maxRetries);
|
|
166
|
-
setTimeout(tryGroup, 200);
|
|
167
|
-
} else {
|
|
168
|
-
Logger.warn('[TabGroup] Tab never reached complete status, grouping anyway. tabId:', tabId);
|
|
169
|
-
doGroup(tabId, groupClientId, baseName);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
tryGroup();
|
|
152
|
+
Logger.info('[TabGroup] Grouping tab immediately for:', baseName);
|
|
153
|
+
doGroup(tabId, groupClientId, baseName);
|
|
174
154
|
}
|
|
175
155
|
|
|
176
156
|
function doGroup(tabId, clientId, baseName, retries) {
|
|
@@ -608,6 +588,7 @@ function checkTabVisibility(tabId) {
|
|
|
608
588
|
pageAddScriptToEvaluateOnNewDocument: pageAddScriptToEvaluateOnNewDocument,
|
|
609
589
|
runtimeRunIfWaitingForDebugger: runtimeRunIfWaitingForDebugger,
|
|
610
590
|
domSetFileInputFiles: domSetFileInputFiles,
|
|
611
|
-
updateTabGroupName: updateTabGroupName
|
|
591
|
+
updateTabGroupName: updateTabGroupName,
|
|
592
|
+
addTabToAutomationGroup: addTabToAutomationGroup
|
|
612
593
|
};
|
|
613
594
|
})();
|
|
@@ -24,6 +24,7 @@ var CDP_HANDLERS = {
|
|
|
24
24
|
|
|
25
25
|
'Tab.getMuteStatus': { type: 'LOCAL', handler: LocalHandler.tabGetMuteStatus },
|
|
26
26
|
'Tab.getGroupInfo': { type: 'LOCAL', handler: LocalHandler.tabGetGroupInfo },
|
|
27
|
+
'Tab.ungroup': { type: 'LOCAL', handler: LocalHandler.tabUngroup },
|
|
27
28
|
|
|
28
29
|
'SystemInfo.getInfo': { type: 'LOCAL', handler: LocalHandler.systemInfoGetInfo },
|
|
29
30
|
'SystemInfo.getProcessInfo': { type: 'LOCAL', handler: LocalHandler.systemInfoGetProcessInfo },
|
|
@@ -409,8 +409,8 @@ var WebSocketManager = (function() {
|
|
|
409
409
|
return;
|
|
410
410
|
}
|
|
411
411
|
var groupId = State.getGroupIdForClient(clientId);
|
|
412
|
-
Logger.info('[Monitor] Tab', tabId, 'groupId=' + (tab.groupId
|
|
413
|
-
if (tab.groupId) return;
|
|
412
|
+
Logger.info('[Monitor] Tab', tabId, 'groupId=' + (tab.groupId > -1 ? tab.groupId : 'none'), 'expectedGroup=' + (groupId > -1 ? groupId : 'none'), 'clientId=' + (clientId || 'none'));
|
|
413
|
+
if (tab.groupId > -1) return;
|
|
414
414
|
Logger.info('[Monitor] Tab', tabId, 'escaped! Forcing regroup for client:', clientId);
|
|
415
415
|
if (groupId) {
|
|
416
416
|
chrome.tabs.group({ tabIds: tabId, groupId: groupId }, function() {
|
package/package.json
CHANGED