cdp-tunnel 1.7.0 → 2.0.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.
|
@@ -13,17 +13,6 @@ importScripts('cdp/index.js');
|
|
|
13
13
|
importScripts('features/screencast.js');
|
|
14
14
|
importScripts('features/automation-badge.js');
|
|
15
15
|
|
|
16
|
-
// 为字符串添加hashCode方法(用于生成颜色索引)
|
|
17
|
-
String.prototype.hashCode = function() {
|
|
18
|
-
var hash = 0;
|
|
19
|
-
for (var i = 0; i < this.length; i++) {
|
|
20
|
-
var char = this.charCodeAt(i);
|
|
21
|
-
hash = ((hash << 5) - hash) + char;
|
|
22
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
23
|
-
}
|
|
24
|
-
return hash;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
16
|
(function() {
|
|
28
17
|
'use strict';
|
|
29
18
|
|
|
@@ -271,7 +260,7 @@ String.prototype.hashCode = function() {
|
|
|
271
260
|
if (groupId) {
|
|
272
261
|
// 为不同的组使用不同的颜色
|
|
273
262
|
var colors = ['blue', 'red', 'yellow', 'green', 'pink', 'purple', 'cyan', 'orange'];
|
|
274
|
-
var colorIndex = Math.abs(
|
|
263
|
+
var colorIndex = Math.abs(CDPUtils.hashCode(groupName)) % colors.length;
|
|
275
264
|
var groupColor = colors[colorIndex];
|
|
276
265
|
|
|
277
266
|
chrome.tabGroups.update(groupId, {
|
|
@@ -171,7 +171,7 @@ var SpecialHandler = (function() {
|
|
|
171
171
|
}
|
|
172
172
|
if (groupId) {
|
|
173
173
|
var colors = ['blue', 'red', 'yellow', 'green', 'pink', 'purple', 'cyan', 'orange'];
|
|
174
|
-
var colorIndex = Math.abs(
|
|
174
|
+
var colorIndex = Math.abs(CDPUtils.hashCode(groupName)) % colors.length;
|
|
175
175
|
|
|
176
176
|
chrome.tabGroups.update(groupId, {
|
|
177
177
|
title: groupName,
|
|
@@ -217,17 +217,6 @@ var SpecialHandler = (function() {
|
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// 为字符串添加hashCode方法(用于生成颜色索引)
|
|
221
|
-
String.prototype.hashCode = function() {
|
|
222
|
-
var hash = 0;
|
|
223
|
-
for (var i = 0; i < this.length; i++) {
|
|
224
|
-
var char = this.charCodeAt(i);
|
|
225
|
-
hash = ((hash << 5) - hash) + char;
|
|
226
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
227
|
-
}
|
|
228
|
-
return hash;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
220
|
function targetActivateTarget(context) {
|
|
232
221
|
var params = context.params;
|
|
233
222
|
var targetId = params && params.targetId;
|
|
@@ -17,9 +17,20 @@ var CDPUtils = (function() {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
function hashCode(str) {
|
|
21
|
+
var hash = 0;
|
|
22
|
+
for (var i = 0; i < str.length; i++) {
|
|
23
|
+
var char = str.charCodeAt(i);
|
|
24
|
+
hash = ((hash << 5) - hash) + char;
|
|
25
|
+
hash = hash & hash;
|
|
26
|
+
}
|
|
27
|
+
return hash;
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
return {
|
|
21
31
|
generateSessionId: generateSessionId,
|
|
22
32
|
getChromeVersion: getChromeVersion,
|
|
23
|
-
sleep: sleep
|
|
33
|
+
sleep: sleep,
|
|
34
|
+
hashCode: hashCode
|
|
24
35
|
};
|
|
25
36
|
})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdp-tunnel",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Chrome
|
|
3
|
+
"version": "2.0.0",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
@@ -19,12 +19,30 @@
|
|
|
19
19
|
"keywords": [
|
|
20
20
|
"cdp",
|
|
21
21
|
"chrome-devtools-protocol",
|
|
22
|
+
"cdp-proxy",
|
|
22
23
|
"playwright",
|
|
23
24
|
"puppeteer",
|
|
24
|
-
"chrome-extension"
|
|
25
|
+
"chrome-extension",
|
|
26
|
+
"browser-automation",
|
|
27
|
+
"web-scraping",
|
|
28
|
+
"remote-debugging",
|
|
29
|
+
"websocket",
|
|
30
|
+
"testing",
|
|
31
|
+
"browser-control"
|
|
25
32
|
],
|
|
26
33
|
"author": "dyyz1993",
|
|
27
34
|
"license": "Apache-2.0",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/dyyz1993/cdp-tunnel.git"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/dyyz1993/cdp-tunnel#readme",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/dyyz1993/cdp-tunnel/issues"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=16.0.0"
|
|
45
|
+
},
|
|
28
46
|
"files": [
|
|
29
47
|
"server/",
|
|
30
48
|
"cli/",
|
package/extension-new/popup.html
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<style>
|
|
6
|
-
body {
|
|
7
|
-
width: 300px;
|
|
8
|
-
padding: 15px;
|
|
9
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
10
|
-
font-size: 14px;
|
|
11
|
-
}
|
|
12
|
-
.status {
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
margin-bottom: 15px;
|
|
16
|
-
}
|
|
17
|
-
.status-dot {
|
|
18
|
-
width: 10px;
|
|
19
|
-
height: 10px;
|
|
20
|
-
border-radius: 50%;
|
|
21
|
-
margin-right: 8px;
|
|
22
|
-
}
|
|
23
|
-
.status-dot.active {
|
|
24
|
-
background-color: #4CAF50;
|
|
25
|
-
}
|
|
26
|
-
.status-dot.inactive {
|
|
27
|
-
background-color: #9E9E9E;
|
|
28
|
-
}
|
|
29
|
-
.config-section {
|
|
30
|
-
margin-top: 15px;
|
|
31
|
-
}
|
|
32
|
-
.config-section label {
|
|
33
|
-
display: block;
|
|
34
|
-
margin-bottom: 5px;
|
|
35
|
-
font-weight: 500;
|
|
36
|
-
}
|
|
37
|
-
.config-section input {
|
|
38
|
-
width: 100%;
|
|
39
|
-
padding: 8px;
|
|
40
|
-
border: 1px solid #ddd;
|
|
41
|
-
border-radius: 4px;
|
|
42
|
-
box-sizing: border-box;
|
|
43
|
-
}
|
|
44
|
-
.config-section button {
|
|
45
|
-
margin-top: 10px;
|
|
46
|
-
padding: 8px 16px;
|
|
47
|
-
background-color: #2196F3;
|
|
48
|
-
color: white;
|
|
49
|
-
border: none;
|
|
50
|
-
border-radius: 4px;
|
|
51
|
-
cursor: pointer;
|
|
52
|
-
}
|
|
53
|
-
.config-section button:hover {
|
|
54
|
-
background-color: #1976D2;
|
|
55
|
-
}
|
|
56
|
-
</style>
|
|
57
|
-
</head>
|
|
58
|
-
<body>
|
|
59
|
-
<div class="status">
|
|
60
|
-
<div class="status-dot active" id="statusDot"></div>
|
|
61
|
-
<span id="statusText">已激活</span>
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
<div class="config-section">
|
|
65
|
-
<label>WebSocket 地址</label>
|
|
66
|
-
<input type="text" id="wsAddress" placeholder="ws://localhost:9221/client">
|
|
67
|
-
<button id="saveBtn">保存</button>
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<script src="popup.js"></script>
|
|
71
|
-
</body>
|
|
72
|
-
</html>
|
package/extension-new/popup.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
document.addEventListener('DOMContentLoaded', function() {
|
|
2
|
-
var statusDot = document.getElementById('statusDot');
|
|
3
|
-
var statusText = document.getElementById('statusText');
|
|
4
|
-
var wsAddressInput = document.getElementById('wsAddress');
|
|
5
|
-
var saveBtn = document.getElementById('saveBtn');
|
|
6
|
-
|
|
7
|
-
chrome.storage.local.get(['wsAddress'], function(result) {
|
|
8
|
-
if (result.wsAddress) {
|
|
9
|
-
wsAddressInput.value = result.wsAddress;
|
|
10
|
-
} else {
|
|
11
|
-
wsAddressInput.value = 'ws://localhost:9221/plugin';
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
saveBtn.addEventListener('click', function() {
|
|
16
|
-
var newAddress = wsAddressInput.value.trim();
|
|
17
|
-
if (newAddress) {
|
|
18
|
-
chrome.storage.local.set({ wsAddress: newAddress }, function() {
|
|
19
|
-
statusText.textContent = '已保存,正在重连...';
|
|
20
|
-
|
|
21
|
-
chrome.runtime.sendMessage({ type: 'reconnect' }, function(response) {
|
|
22
|
-
if (response && response.success) {
|
|
23
|
-
statusText.textContent = '已激活';
|
|
24
|
-
} else {
|
|
25
|
-
statusText.textContent = '重连失败';
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
statusDot.classList.add('active');
|
|
33
|
-
statusText.textContent = '已激活';
|
|
34
|
-
});
|