cdp-tunnel 2.5.1 → 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.
- package/extension-new/cdp/handler/local.js +15 -1
- package/extension-new/cdp/handler/special.js +34 -9
- package/extension-new/cdp/index.js +1 -0
- package/extension-new/manifest.json +1 -1
- package/extension-new/utils/config.js +1 -1
- package/extension-new/utils/helpers.js +2 -1
- package/package.json +1 -1
|
@@ -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
|
})();
|
|
@@ -132,7 +132,9 @@ var SpecialHandler = (function() {
|
|
|
132
132
|
function addTabToAutomationGroup(tabId, clientId) {
|
|
133
133
|
Logger.info('[TabGroup] Starting addTabToAutomationGroup for tabId:', tabId, 'clientId:', clientId);
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
setTimeout(function() {
|
|
136
|
+
muteTabIfNeeded(tabId);
|
|
137
|
+
}, 200);
|
|
136
138
|
|
|
137
139
|
var groupClientId = clientId;
|
|
138
140
|
if (!groupClientId) {
|
|
@@ -140,9 +142,32 @@ var SpecialHandler = (function() {
|
|
|
140
142
|
return;
|
|
141
143
|
}
|
|
142
144
|
var baseName = CDPUtils.getGroupBaseName(groupClientId);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
+
} else {
|
|
162
|
+
Logger.warn('[TabGroup] Tab never reached complete status, grouping anyway. tabId:', tabId);
|
|
163
|
+
doGroup(tabId, groupClientId, baseName);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
tryGroup();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function doGroup(tabId, clientId, baseName) {
|
|
146
171
|
chrome.tabGroups.query({}, function(allGroups) {
|
|
147
172
|
var existing = CDPUtils.findGroupByName(allGroups, baseName);
|
|
148
173
|
if (existing) {
|
|
@@ -150,8 +175,8 @@ var SpecialHandler = (function() {
|
|
|
150
175
|
if (chrome.runtime.lastError) {
|
|
151
176
|
Logger.error('[TabGroup] Failed to add tab to group:', chrome.runtime.lastError.message);
|
|
152
177
|
} else {
|
|
153
|
-
State.setGroupIdForClient(
|
|
154
|
-
updateTabGroupName(
|
|
178
|
+
State.setGroupIdForClient(clientId, existing.id);
|
|
179
|
+
updateTabGroupName(clientId);
|
|
155
180
|
Logger.info('[TabGroup] Tab', tabId, 'added to existing group:', existing.id);
|
|
156
181
|
}
|
|
157
182
|
});
|
|
@@ -164,14 +189,14 @@ var SpecialHandler = (function() {
|
|
|
164
189
|
if (groupId) {
|
|
165
190
|
chrome.tabGroups.update(groupId, {
|
|
166
191
|
title: baseName,
|
|
167
|
-
color: CDPUtils.getGroupColorForClient(
|
|
192
|
+
color: CDPUtils.getGroupColorForClient(clientId),
|
|
168
193
|
collapsed: true
|
|
169
194
|
}, function() {
|
|
170
195
|
if (chrome.runtime.lastError) {
|
|
171
196
|
Logger.error('[TabGroup] Failed to update group:', chrome.runtime.lastError.message);
|
|
172
197
|
} else {
|
|
173
|
-
State.setGroupIdForClient(
|
|
174
|
-
updateTabGroupName(
|
|
198
|
+
State.setGroupIdForClient(clientId, groupId);
|
|
199
|
+
updateTabGroupName(clientId);
|
|
175
200
|
Logger.info('[TabGroup] Created new group:', groupId, 'with tab:', tabId);
|
|
176
201
|
}
|
|
177
202
|
});
|
|
@@ -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 },
|
|
@@ -44,7 +44,8 @@ var CDPUtils = (function() {
|
|
|
44
44
|
|
|
45
45
|
function buildGroupName(clientId) {
|
|
46
46
|
if (!clientId) return 'CDP';
|
|
47
|
-
|
|
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