cdp-tunnel 1.2.0 → 1.3.0

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.
@@ -216,6 +216,18 @@ String.prototype.hashCode = function() {
216
216
  var sessionId = CDPUtils.generateSessionId();
217
217
  State.mapSession(sessionId, tabId, targetId);
218
218
 
219
+ Config.getAutoMute(function(enabled) {
220
+ if (enabled) {
221
+ chrome.tabs.update(tabId, { muted: true }, function() {
222
+ if (chrome.runtime.lastError) {
223
+ Logger.error('[TabMute] Failed to mute tab ' + tabId + ':', chrome.runtime.lastError.message);
224
+ } else {
225
+ Logger.info('[TabMute] Tab muted:', tabId);
226
+ }
227
+ });
228
+ }
229
+ });
230
+
219
231
  // 将标签页添加到CDP组(添加延迟等待)
220
232
  setTimeout(function() {
221
233
  // 获取openerTabId对应的clientId
@@ -1,4 +1,17 @@
1
1
  var SpecialHandler = (function() {
2
+ function muteTabIfNeeded(tabId) {
3
+ Config.getAutoMute(function(enabled) {
4
+ if (!enabled) return;
5
+ chrome.tabs.update(tabId, { muted: true }, function() {
6
+ if (chrome.runtime.lastError) {
7
+ Logger.error('[TabMute] Failed to mute tab ' + tabId + ':', chrome.runtime.lastError.message);
8
+ } else {
9
+ Logger.info('[TabMute] Tab muted:', tabId);
10
+ }
11
+ });
12
+ });
13
+ }
14
+
2
15
  function targetSetAutoAttach(context) {
3
16
  var params = context.params;
4
17
  State.setAutoAttachConfig({
@@ -116,6 +129,8 @@ var SpecialHandler = (function() {
116
129
  function addTabToAutomationGroup(tabId, clientId) {
117
130
  Logger.info('[TabGroup] Starting addTabToAutomationGroup for tabId:', tabId, 'clientId:', clientId);
118
131
 
132
+ muteTabIfNeeded(tabId);
133
+
119
134
  var groupName;
120
135
  var groupClientId = clientId;
121
136
 
@@ -458,6 +458,35 @@
458
458
  font-size: 12px;
459
459
  }
460
460
 
461
+ .toggle-switch {
462
+ position: relative;
463
+ display: inline-block;
464
+ width: 40px;
465
+ height: 22px;
466
+ }
467
+ .toggle-switch input { opacity: 0; width: 0; height: 0; }
468
+ .toggle-slider {
469
+ position: absolute;
470
+ cursor: pointer;
471
+ top: 0; left: 0; right: 0; bottom: 0;
472
+ background-color: #ccc;
473
+ transition: .3s;
474
+ border-radius: 22px;
475
+ }
476
+ .toggle-slider:before {
477
+ position: absolute;
478
+ content: "";
479
+ height: 16px;
480
+ width: 16px;
481
+ left: 3px;
482
+ bottom: 3px;
483
+ background-color: white;
484
+ transition: .3s;
485
+ border-radius: 50%;
486
+ }
487
+ input:checked + .toggle-slider { background-color: #4CAF50; }
488
+ input:checked + .toggle-slider:before { transform: translateX(18px); }
489
+
461
490
  .divider {
462
491
  height: 1px;
463
492
  background: #e5e7eb;
@@ -721,6 +750,16 @@
721
750
  </div>
722
751
  <button class="btn btn-primary btn-block" id="connectBtn">🔗 保存并连接</button>
723
752
 
753
+ <div class="config-item" style="display: flex; justify-content: space-between; align-items: center; margin-top: 12px;">
754
+ <label style="font-size: 13px; color: #666;">
755
+ 🔇 自动静音新标签页
756
+ </label>
757
+ <label class="toggle-switch">
758
+ <input type="checkbox" id="autoMuteToggle" checked>
759
+ <span class="toggle-slider"></span>
760
+ </label>
761
+ </div>
762
+
724
763
  <div class="divider"></div>
725
764
 
726
765
  <div class="usage-guide">
@@ -258,8 +258,16 @@
258
258
  elements.serverAddress.value = result.wsAddress;
259
259
  }
260
260
  });
261
+ chrome.storage.local.get(['autoMute'], function(result) {
262
+ document.getElementById('autoMuteToggle').checked = result.autoMute !== false;
263
+ });
261
264
  }
262
265
 
266
+ document.getElementById('autoMuteToggle').addEventListener('change', function(e) {
267
+ chrome.storage.local.set({ autoMute: e.target.checked });
268
+ addLog(e.target.checked ? '🔇 自动静音已开启' : '🔊 自动静音已关闭', 'action');
269
+ });
270
+
263
271
  fetchState();
264
272
 
265
273
  setInterval(fetchState, 5000);
@@ -16,5 +16,14 @@ var Config = {
16
16
  chrome.storage.local.get(['wsAddress'], function(result) {
17
17
  callback(result.wsAddress || Config.WS_URL);
18
18
  });
19
+ },
20
+ AUTO_MUTE: true,
21
+ getAutoMute: function(callback) {
22
+ chrome.storage.local.get(['autoMute'], function(result) {
23
+ callback(result.autoMute !== false);
24
+ });
25
+ },
26
+ setAutoMute: function(enabled, callback) {
27
+ chrome.storage.local.set({ autoMute: enabled }, callback);
19
28
  }
20
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-tunnel",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Chrome Extension CDP Proxy - 通过 Chrome 扩展将 chrome.debugger API 暴露为 WebSocket 端点",
5
5
  "main": "server/proxy-server.js",
6
6
  "bin": "./cli/index.js",