cdp-tunnel 2.8.3 → 2.8.4
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.
|
@@ -341,7 +341,7 @@ importScripts('features/automation-badge.js');
|
|
|
341
341
|
chrome.runtime.onInstalled.addListener(function(details) {
|
|
342
342
|
Logger.info('[Runtime] Extension installed/updated:', details.reason);
|
|
343
343
|
State.persist(null, false);
|
|
344
|
-
setBadgeStatus('
|
|
344
|
+
setBadgeStatus('OFF');
|
|
345
345
|
init();
|
|
346
346
|
});
|
|
347
347
|
|
|
@@ -258,8 +258,12 @@
|
|
|
258
258
|
function loadConnectionStatuses() {
|
|
259
259
|
if (typeof chrome !== 'undefined' && chrome.runtime) {
|
|
260
260
|
chrome.runtime.sendMessage({ type: 'get-connection-statuses' }, function(response) {
|
|
261
|
-
if (response && response.
|
|
262
|
-
|
|
261
|
+
if (response && response.connections) {
|
|
262
|
+
var statuses = {};
|
|
263
|
+
response.connections.forEach(function(conn) {
|
|
264
|
+
statuses[conn.id] = conn.status;
|
|
265
|
+
});
|
|
266
|
+
state.connectionStatuses = statuses;
|
|
263
267
|
}
|
|
264
268
|
loadAndRenderConnections();
|
|
265
269
|
});
|
|
@@ -431,6 +435,8 @@
|
|
|
431
435
|
addLog(message.logType, message.message);
|
|
432
436
|
} else if (message.type === 'connections-updated') {
|
|
433
437
|
loadAndRenderConnections();
|
|
438
|
+
} else if (message.type === 'connection-status-changed') {
|
|
439
|
+
loadConnectionStatuses();
|
|
434
440
|
}
|
|
435
441
|
});
|
|
436
442
|
}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
function updateBadgeFromAllConnections() {
|
|
2
|
+
var hasConnected = false;
|
|
3
|
+
var hasEnabled = false;
|
|
4
|
+
ConnectionManager.forEachConnection(function(entry) {
|
|
5
|
+
var ws = entry.state.getWs();
|
|
6
|
+
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
7
|
+
hasConnected = true;
|
|
8
|
+
}
|
|
9
|
+
if (entry.config && entry.config.enabled !== false) {
|
|
10
|
+
hasEnabled = true;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var status;
|
|
14
|
+
if (hasConnected) {
|
|
15
|
+
status = 'ON';
|
|
16
|
+
} else if (hasEnabled) {
|
|
17
|
+
status = 'ERR';
|
|
18
|
+
} else {
|
|
19
|
+
status = 'OFF';
|
|
20
|
+
}
|
|
21
|
+
setBadgeStatus(status);
|
|
22
|
+
chrome.runtime.sendMessage({ type: 'connection-status-changed' }).catch(function() {});
|
|
23
|
+
}
|
|
24
|
+
|
|
1
25
|
var WebSocketConnection = (function() {
|
|
2
26
|
function WebSocketConnection(connectionId, state, config) {
|
|
3
27
|
this.connectionId = connectionId;
|
|
@@ -24,7 +48,7 @@ var WebSocketConnection = (function() {
|
|
|
24
48
|
wsUrl += sep + 'pluginId=' + encodeURIComponent(pluginId);
|
|
25
49
|
}
|
|
26
50
|
Logger.info('[WS:' + self.connectionId + '] Connecting to', wsUrl);
|
|
27
|
-
|
|
51
|
+
updateBadgeFromAllConnections();
|
|
28
52
|
|
|
29
53
|
try {
|
|
30
54
|
ws = new WebSocket(wsUrl);
|
|
@@ -32,7 +56,7 @@ var WebSocketConnection = (function() {
|
|
|
32
56
|
|
|
33
57
|
ws.onopen = function() {
|
|
34
58
|
Logger.info('[WS:' + self.connectionId + '] Connected');
|
|
35
|
-
|
|
59
|
+
updateBadgeFromAllConnections();
|
|
36
60
|
self.state.clearReconnectTimer();
|
|
37
61
|
self._processQueue();
|
|
38
62
|
self._broadcastStateUpdate();
|
|
@@ -43,14 +67,14 @@ var WebSocketConnection = (function() {
|
|
|
43
67
|
|
|
44
68
|
ws.onclose = function(event) {
|
|
45
69
|
Logger.info('[WS:' + self.connectionId + '] Closed:', event.code, event.reason);
|
|
46
|
-
|
|
70
|
+
updateBadgeFromAllConnections();
|
|
47
71
|
self._scheduleReconnect();
|
|
48
72
|
self._broadcastStateUpdate();
|
|
49
73
|
};
|
|
50
74
|
|
|
51
75
|
ws.onerror = function(error) {
|
|
52
76
|
Logger.error('[WS:' + self.connectionId + '] Error:', error);
|
|
53
|
-
|
|
77
|
+
updateBadgeFromAllConnections();
|
|
54
78
|
self._broadcastStateUpdate();
|
|
55
79
|
};
|
|
56
80
|
|
|
@@ -58,9 +82,9 @@ var WebSocketConnection = (function() {
|
|
|
58
82
|
self._handleRawMessage(event.data);
|
|
59
83
|
};
|
|
60
84
|
} catch (error) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
Logger.error('[WS:' + self.connectionId + '] Failed to create:', error);
|
|
86
|
+
updateBadgeFromAllConnections();
|
|
87
|
+
self._scheduleReconnect();
|
|
64
88
|
}
|
|
65
89
|
});
|
|
66
90
|
};
|
package/extension-new/popup.js
CHANGED
|
@@ -76,4 +76,10 @@
|
|
|
76
76
|
versionLink.textContent = 'v' + manifest.version;
|
|
77
77
|
|
|
78
78
|
loadState();
|
|
79
|
+
|
|
80
|
+
chrome.runtime.onMessage.addListener(function(message) {
|
|
81
|
+
if (message.type === 'connection-status-changed' || message.type === 'stateUpdate') {
|
|
82
|
+
loadState();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
79
85
|
})();
|
package/package.json
CHANGED