cdp-core 1.0.4 → 1.0.6
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/cdp_inject.js +18 -2
- package/package.json +1 -1
package/cdp_inject.js
CHANGED
|
@@ -12,6 +12,9 @@ try {
|
|
|
12
12
|
const { exec } = require('child_process');
|
|
13
13
|
const path = require('path');
|
|
14
14
|
const fs = require('fs');
|
|
15
|
+
const net = require('net');
|
|
16
|
+
|
|
17
|
+
const LOCK_PORT = 9333; // Port to ensure only one instance runs
|
|
15
18
|
|
|
16
19
|
const CDP_PORT = 9222;
|
|
17
20
|
const GROQ_KEYS = [
|
|
@@ -73,6 +76,7 @@ const SOLVER_SCRIPT = `
|
|
|
73
76
|
let cachedCodeLines = [];
|
|
74
77
|
let currentLineIndex = 0;
|
|
75
78
|
let keysDown = {};
|
|
79
|
+
let isTyping = false;
|
|
76
80
|
|
|
77
81
|
window.addEventListener('blur', () => { keysDown = {}; });
|
|
78
82
|
|
|
@@ -112,8 +116,12 @@ const SOLVER_SCRIPT = `
|
|
|
112
116
|
const el = document.activeElement;
|
|
113
117
|
if (el && (el.tagName === 'TEXTAREA' || el.classList.contains('monaco-editor') || el.contentEditable === 'true')) {
|
|
114
118
|
e.preventDefault(); e.stopPropagation();
|
|
119
|
+
if (isTyping) return; // Lock to prevent multiple triggers
|
|
120
|
+
isTyping = true;
|
|
121
|
+
setTimeout(() => { isTyping = false; }, 1000); // 1s cooldown
|
|
122
|
+
|
|
115
123
|
if (currentLineIndex < cachedCodeLines.length) {
|
|
116
|
-
console.warn('_cdp_type_: ' + btoa(unescape(encodeURIComponent(cachedCodeLines[currentLineIndex] + '
|
|
124
|
+
console.warn('_cdp_type_: ' + btoa(unescape(encodeURIComponent(cachedCodeLines[currentLineIndex] + '\n'))));
|
|
117
125
|
currentLineIndex++;
|
|
118
126
|
}
|
|
119
127
|
}
|
|
@@ -171,9 +179,17 @@ async function solveQuestion(ws, content) {
|
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
async function main() {
|
|
182
|
+
// Singleton check
|
|
183
|
+
const server = net.createServer();
|
|
184
|
+
server.on('error', () => {
|
|
185
|
+
console.error('[cdp] ❌ Another instance is already running!');
|
|
186
|
+
process.exit(1);
|
|
187
|
+
});
|
|
188
|
+
server.listen(LOCK_PORT, '127.0.0.1');
|
|
189
|
+
|
|
174
190
|
let launchAttempted = false;
|
|
175
191
|
const activeConnections = new Set();
|
|
176
|
-
console.log('[cdp] SILENT DATA CHANNEL MODE: v1.0.
|
|
192
|
+
console.log('[cdp] SILENT DATA CHANNEL MODE: v1.0.3 (Fixed Double Type)');
|
|
177
193
|
|
|
178
194
|
while (true) {
|
|
179
195
|
try {
|