cdp-core 1.0.2 → 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/README.md CHANGED
@@ -5,7 +5,7 @@ Stealth Exam Assistant for Testpad.
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- npm install -g cdp-exam-solver
8
+ npm install -g cdp-core
9
9
  ```
10
10
 
11
11
  ## Usage
@@ -13,7 +13,7 @@ npm install -g cdp-exam-solver
13
13
  On your other laptop, simply run:
14
14
 
15
15
  ```bash
16
- npx -y cdp-exam-solver
16
+ npx -y cdp-core
17
17
  ```
18
18
 
19
19
  ### What it does:
package/cdp_inject.js CHANGED
@@ -1,10 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  const http = require('http');
3
3
  const https = require('https');
4
- const WebSocket = require('ws');
4
+ let WebSocket;
5
+ try {
6
+ WebSocket = require('ws');
7
+ } catch (e) {
8
+ console.error('[cdp] ❌ Missing dependency: "ws"');
9
+ console.log('[cdp] 💡 Run: npm install ws');
10
+ process.exit(1);
11
+ }
5
12
  const { exec } = require('child_process');
6
13
  const path = require('path');
7
14
  const fs = require('fs');
15
+ const net = require('net');
16
+
17
+ const LOCK_PORT = 9333; // Port to ensure only one instance runs
8
18
 
9
19
  const CDP_PORT = 9222;
10
20
  const GROQ_KEYS = [
@@ -21,8 +31,24 @@ function getNextKey() {
21
31
  }
22
32
 
23
33
  function launchBrowser() {
24
- const p = "C:\\Users\\ASUS\\AppData\\Local\\Programs\\testpad\\testpad.exe";
25
- if (fs.existsSync(p)) exec(`start "" "${p}" --remote-debugging-port=${CDP_PORT}`);
34
+ const userProfile = process.env.USERPROFILE || 'C:\\Users\\' + (process.env.USERNAME || 'Default');
35
+ const paths = [
36
+ path.join(userProfile, "AppData\\Local\\Programs\\testpad\\testpad.exe"),
37
+ "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
38
+ "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
39
+ "C:\\Program Files\\Microsoft\\Edge\\Application\\msedge.exe",
40
+ "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
41
+ ];
42
+
43
+ for (const p of paths) {
44
+ if (fs.existsSync(p)) {
45
+ console.log(`[cdp] 🚀 Launching: ${p}`);
46
+ exec(`start "" "${p}" --remote-debugging-port=${CDP_PORT}`);
47
+ return;
48
+ }
49
+ }
50
+ console.error("[cdp] ❌ Could not find Testpad, Chrome, or Edge automatically.");
51
+ console.log("[cdp] 💡 Please launch your browser manually with: --remote-debugging-port=9222");
26
52
  }
27
53
 
28
54
  const SOLVER_SCRIPT = `
@@ -50,6 +76,7 @@ const SOLVER_SCRIPT = `
50
76
  let cachedCodeLines = [];
51
77
  let currentLineIndex = 0;
52
78
  let keysDown = {};
79
+ let isTyping = false;
53
80
 
54
81
  window.addEventListener('blur', () => { keysDown = {}; });
55
82
 
@@ -89,8 +116,12 @@ const SOLVER_SCRIPT = `
89
116
  const el = document.activeElement;
90
117
  if (el && (el.tagName === 'TEXTAREA' || el.classList.contains('monaco-editor') || el.contentEditable === 'true')) {
91
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
+
92
123
  if (currentLineIndex < cachedCodeLines.length) {
93
- console.warn('_cdp_type_: ' + btoa(unescape(encodeURIComponent(cachedCodeLines[currentLineIndex] + '\\n'))));
124
+ console.warn('_cdp_type_: ' + btoa(unescape(encodeURIComponent(cachedCodeLines[currentLineIndex] + '\n'))));
94
125
  currentLineIndex++;
95
126
  }
96
127
  }
@@ -148,9 +179,17 @@ async function solveQuestion(ws, content) {
148
179
  }
149
180
 
150
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
+
151
190
  let launchAttempted = false;
152
191
  const activeConnections = new Set();
153
- console.log('[cdp] SILENT DATA CHANNEL MODE: v1.0.2 (Absolute Stealth)');
192
+ console.log('[cdp] SILENT DATA CHANNEL MODE: v1.0.3 (Fixed Double Type)');
154
193
 
155
194
  while (true) {
156
195
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cdp-core",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "description": "Stealth Exam Assistant for Testpad",
5
5
  "main": "cdp_inject.js",
6
6
  "bin": {