exiouss 1.0.1

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.

Potentially problematic release.


This version of exiouss might be problematic. Click here for more details.

package/main.js ADDED
@@ -0,0 +1,833 @@
1
+ // ═══════════════════════════════════════════
2
+ // GLOBAL STEALTH BOOT (MUST BE FIRST)
3
+ // ═══════════════════════════════════════════
4
+ const { app, BrowserWindow, screen, ipcMain, globalShortcut, clipboard, nativeImage, desktopCapturer, session } = require('electron');
5
+ app.commandLine.appendSwitch('disable-blink-features', 'AutomationControlled');
6
+ app.commandLine.appendSwitch('disable-features', 'UserAgentClientHint');
7
+ app.commandLine.appendSwitch('no-sandbox');
8
+ app.commandLine.appendSwitch('disable-site-isolation-trials');
9
+
10
+ // CRITICAL: Prevent Chromium from pausing DOM updates when window is "hidden"
11
+ app.commandLine.appendSwitch('disable-renderer-backgrounding');
12
+ app.commandLine.appendSwitch('disable-background-timer-throttling');
13
+ app.commandLine.appendSwitch('disable-backgrounding-occluded-windows');
14
+ app.commandLine.appendSwitch('disable-features', 'CalculateNativeWinOcclusion');
15
+
16
+ const path = require('path');
17
+ const fs = require('fs');
18
+ const { exec } = require('child_process');
19
+ const { powerSaveBlocker } = require('electron');
20
+
21
+ // 🛡️ POWER SHIELD: Prevent system/renderer suspension
22
+ powerSaveBlocker.start('prevent-app-suspension');
23
+
24
+ // ═══════════════════════════════════════════
25
+ // PROJECT GHOST-MODE 🛸 (Native Stealth)
26
+ // ═══════════════════════════════════════════
27
+ const { uIOhook } = require('uiohook-napi');
28
+ const koffi = require('koffi');
29
+
30
+ // ═══════════════════════════════════════════
31
+ // PROJECT PHANTOM-BATCH v12.0 🛸 (Lex200 Sealed)
32
+ // ═══════════════════════════════════════════
33
+
34
+ let overlayWindow = null;
35
+ let chatgptWin = null;
36
+
37
+ let batchQueue = []; // Array of { img: String, timestamp }
38
+ let isForcedHidden = false; // Start VISIBLE
39
+ let isUiHidden = false; // Alt+E toggle
40
+ let isAdminVisible = false;
41
+ let isPinned = false;
42
+ let isAlwaysOnTop = true;
43
+ let isCombatMode = false; // "Click-Through" Mode (Lex200 Defense)
44
+ let activeSection = "GEN"; // GEN, DEB, APT, PRG
45
+ let promptSent = false;
46
+
47
+ // AMCAT Specialized Prompts — Ignore all page noise, solve ONLY the question
48
+ const SECTION_PROMPTS = {
49
+ "GEN": "IGNORE all navigation, sidebar, comments, similar questions, and UI noise in the text. Focus ONLY on the actual problem/question. Solve with 100% accuracy. Think step-by-step internally. RESPOND WITH ONLY THE FINAL ANSWER on the first line. If MCQ, give only the option letter. If coding, give only the code. Brief explanation below if needed. Please label answers as [Q1], [Q2], etc. if multiple questions were provided.",
50
+ "DEB": "IGNORE page noise. Focus ONLY on the code with the bug. Find the bug. RESPOND WITH ONLY THE CORRECTED CODE on the first line. Label the answer with its question ID (e.g., [Q1]).",
51
+ "APT": "IGNORE page noise. Focus ONLY on the math/aptitude problem. Solve step-by-step internally. RESPOND WITH ONLY THE FINAL NUMBER on the first line. Label as [Q1], [Q2], etc.",
52
+ "PRG": "IGNORE page noise. Focus ONLY on the programming problem statement, examples, and constraints. Write a complete, optimized, correct solution in C++ as a LeetCode Solution class with the correct function signature. The code must be ready to paste directly into LeetCode. RESPOND WITH ONLY THE CODE. Label as [Q1], [Q2], etc."
53
+ };
54
+
55
+ // Configuration State
56
+ let SYSTEM_PROMPT = "IGNORE all UI noise. Solve with 100% accuracy. For procedural tasks or configuration steps (like AWS, Linux, Networking), RESPOND WITH HUMAN-LIKE, STEP-BY-STEP INSTRUCTIONS. Each step should be a clear action. Label answers as [Q1], [Q2], etc. inside your response.";
57
+
58
+ let PROXY_RULE = "";
59
+
60
+ // ═══════════════════════════════════════════
61
+ // ENVIRONMENT SELF-HEALING
62
+ // ═══════════════════════════════════════════
63
+ function checkEnvironment() {
64
+ console.log('[SYSTEM] Verifying system dependencies...');
65
+
66
+ // Check for Admin rights (RECRUIT: Warn if non-admin)
67
+ exec('net session', (err) => {
68
+ if (err) {
69
+ console.warn('[SECURITY] App not running as Administrator.');
70
+ } else {
71
+ console.log('[SECURITY] Running with Administrator privileges.');
72
+ }
73
+ });
74
+ }
75
+
76
+ const configPath = path.join(process.cwd(), 'config.json');
77
+
78
+ // Load User Config if exists
79
+ if (fs.existsSync(configPath)) {
80
+ try {
81
+ const userConfig = JSON.parse(fs.readFileSync(configPath, 'utf8'));
82
+ if (userConfig.prompt) SYSTEM_PROMPT = userConfig.prompt;
83
+ if (userConfig.proxy) PROXY_RULE = userConfig.proxy;
84
+ } catch (e) {
85
+ console.error('[CONFIG] Failed to parse config.json, using default prompt.');
86
+ }
87
+ } else {
88
+ // Create default config if missing
89
+ try {
90
+ fs.writeFileSync(configPath, JSON.stringify({
91
+ prompt: SYSTEM_PROMPT,
92
+ proxy: ""
93
+ }, null, 4));
94
+ console.log('[CONFIG] Default config.json created.');
95
+ } catch (e) {
96
+ console.error('[CONFIG] Failed to create default config.json');
97
+ }
98
+ }
99
+
100
+ // Override with CLI Arg if provided (--prompt="..." or --proxy="...")
101
+ const promptArg = process.argv.find(arg => arg.startsWith('--prompt='));
102
+ if (promptArg) SYSTEM_PROMPT = promptArg.split('=')[1];
103
+
104
+ const proxyArg = process.argv.find(arg => arg.startsWith('--proxy='));
105
+ if (proxyArg) PROXY_RULE = proxyArg.split('=')[1];
106
+
107
+ // Mouse Analytics
108
+ let lastMousePos = { x: 0, y: 0 };
109
+ let edgeCooldown = 0;
110
+ let edgeActive = { left: false, right: false }; // Track if mouse is currently on edge
111
+ let wasVisible = true; // Sync state
112
+ // UI State
113
+ let lastOpacity = -1;
114
+
115
+ // ═══════════════════════════════════════════
116
+ // WINDOW CREATION
117
+ // ═══════════════════════════════════════════
118
+
119
+ function createOverlayWindow() {
120
+ overlayWindow = new BrowserWindow({
121
+ width: 140, height: 180, transparent: true, frame: false, alwaysOnTop: true,
122
+ skipTaskbar: true, resizable: false, focusable: false,
123
+ webPreferences: { nodeIntegration: true, contextIsolation: false }
124
+ });
125
+ overlayWindow.loadFile('index.html');
126
+
127
+ // Layer 1: System Level Stealth
128
+ overlayWindow.setAlwaysOnTop(true, 'screen-saver', 100);
129
+ overlayWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
130
+
131
+ // Layer 2: Ultimate Stealth (True Invisibility)
132
+ setUltimateStealth(overlayWindow);
133
+
134
+ overlayWindow.setOpacity(0.9);
135
+ overlayWindow.showInactive();
136
+ }
137
+
138
+ function setUltimateStealth(window) {
139
+ if (!window || process.platform !== 'win32') return;
140
+ try {
141
+ const user32 = koffi.load('user32.dll');
142
+ const SetWindowDisplayAffinity = user32.func('bool __stdcall SetWindowDisplayAffinity(intptr hWnd, uint32_t dwAffinity)');
143
+ const SetWindowPos = user32.func('bool __stdcall SetWindowPos(intptr hWnd, intptr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags)');
144
+ const GetForegroundWindow = user32.func('intptr __stdcall GetForegroundWindow()');
145
+
146
+ // Define mouse_event globally or within this scope if needed
147
+ global.mouse_event = user32.func('void __stdcall mouse_event(uint32_t dwFlags, uint32_t dx, uint32_t dy, uint32_t dwData, uintptr dwExtraInfo)');
148
+ global.MOUSEEVENTF_WHEEL = 0x0800;
149
+
150
+ const handle = window.getNativeWindowHandle();
151
+ const hwnd = handle.readUInt32LE();
152
+
153
+
154
+ // 🛡️ LAYER 1: Capture Protection
155
+ const result = SetWindowDisplayAffinity(hwnd, 0x00000011);
156
+ if (result) {
157
+ console.log('🛡️ STEALTH: WDA_EXCLUDEFROMCAPTURE Activated.');
158
+ } else {
159
+ window.setContentProtection(true);
160
+ }
161
+
162
+ // 🛡️ LAYER 2: Z-ORDER DOMINANCE LOOP (Fights SEB for the Top)
163
+ // SEB constantly tries to be the topmost window. We fight back every 100ms.
164
+ setInterval(() => {
165
+ if (window.isDestroyed()) return;
166
+
167
+ // SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE = 0x0001 | 0x0002 | 0x0040 | 0x0010 = 0x0053
168
+ // HWND_TOPMOST = -1
169
+ SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0053);
170
+
171
+ // Re-assert alwaysOnTop status for Chromium's internal logic
172
+ if (isAlwaysOnTop) {
173
+ window.setAlwaysOnTop(true, 'screen-saver', 100);
174
+ }
175
+ }, 100);
176
+
177
+ } catch (e) {
178
+ console.warn('🛡️ koffi Stealth Failure:', e.message);
179
+ window.setContentProtection(true);
180
+ }
181
+ }
182
+
183
+ // ═══════════════════════════════════════════
184
+ // STEALTH HANDSHAKE (Active Stealth Bridge)
185
+ // ═══════════════════════════════════════════
186
+
187
+ function createBridge(name, url, partition) {
188
+ const win = new BrowserWindow({
189
+ width: 1100, height: 850, x: -10000, y: -10000, show: true, // Off-screen full render (prevents focus steal)
190
+ skipTaskbar: true, frame: false, transparent: true, opacity: 0.01,
191
+ webPreferences: {
192
+ partition: `persist:${partition}`,
193
+ contextIsolation: true,
194
+ nodeIntegration: false,
195
+ javascript: true,
196
+ webSecurity: true,
197
+ backgroundThrottling: false,
198
+ offscreen: false
199
+ }
200
+ });
201
+
202
+ // 🛡️ ULTIMATE STEALTH: Hide from all capture tools even while at (0,0)
203
+ setUltimateStealth(win);
204
+
205
+ // High-Trust Firefox User Agent
206
+ const highTrustUA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0";
207
+ const sess = session.fromPartition(`persist:${partition}`);
208
+ sess.setUserAgent(highTrustUA);
209
+
210
+ sess.setPermissionRequestHandler((webContents, permission, callback) => {
211
+ if (permission === 'notifications') return callback(false);
212
+ callback(true);
213
+ });
214
+
215
+ win.webContents.setUserAgent(highTrustUA);
216
+
217
+ // Deep Stealth Fingerprint (Enhanced for Resilience)
218
+ win.webContents.on('dom-ready', () => {
219
+ win.webContents.executeJavaScript(`
220
+ // Security/Bot Detection Bypass
221
+ Object.defineProperty(navigator, 'webdriver', { get: () => false });
222
+ Object.defineProperty(navigator, 'platform', { get: () => 'Win32' });
223
+ Object.defineProperty(navigator, 'deviceMemory', { get: () => 16 });
224
+
225
+ // Mask Visibility API (Force "Running" state)
226
+ Object.defineProperty(document, 'visibilityState', { get: () => 'visible', configurable: true });
227
+ Object.defineProperty(document, 'hidden', { get: () => false, configurable: true });
228
+ document.dispatchEvent(new Event('visibilitychange'));
229
+
230
+ // State Force Injection
231
+ window.isSleeping = false;
232
+ window.isRunning = true;
233
+
234
+ // Animation Heartbeat (Prevents renderer sleep)
235
+ setInterval(() => {
236
+ window.dispatchEvent(new Event('mousemove'));
237
+ if (window.requestAnimationFrame) {
238
+ window.requestAnimationFrame(() => {});
239
+ }
240
+ }, 1000);
241
+
242
+ // Mock Focus
243
+ try { document.hasFocus = () => true; } catch(e) {}
244
+
245
+ "Injection Success";
246
+ `).catch(err => console.error("[DOM-READY ERR]", err));
247
+ });
248
+
249
+ win.loadURL(url);
250
+
251
+ win.on('close', (e) => {
252
+ e.preventDefault();
253
+ win.setBounds({ x: -10000, y: -10000, width: 1100, height: 850 });
254
+ isAdminVisible = false;
255
+ });
256
+ return win;
257
+ }
258
+
259
+ // ═══════════════════════════════════════════
260
+ // CORE WORKFLOW: CAPTURE -> BATCH -> STRIKE
261
+ // ═══════════════════════════════════════════
262
+
263
+ async function captureImageQuestion() {
264
+ if (batchQueue.length >= 10) return;
265
+ console.log(`[CAPTURE] Using Stealth GDI Memory Capture (Zero-Screenshot)...`);
266
+
267
+ const psPath = path.join(__dirname, 'bin', 'stealth_capture.ps1');
268
+ const cmd = `powershell -ExecutionPolicy Bypass -File "${psPath}"`;
269
+
270
+ // Increase buffer size for Base64 image data and PREVENT CONSOLE FLASH
271
+ exec(cmd, { maxBuffer: 1024 * 1024 * 10, windowsHide: true }, (error, stdout, stderr) => {
272
+ if (error) {
273
+ console.error(`[CAPTURE] GDI Error: ${error.message}`);
274
+ return;
275
+ }
276
+ const dataUrl = stdout.trim();
277
+ if (dataUrl && dataUrl.startsWith("data:image")) {
278
+ batchQueue.push({ img: dataUrl, text: null, time: Date.now() });
279
+ console.log(`[QUEUE] Added stealth image ${batchQueue.length}/10`);
280
+ updateUI();
281
+ } else {
282
+ console.warn(`[CAPTURE] Failed to get pixel data: ${dataUrl}`);
283
+ }
284
+ });
285
+ }
286
+
287
+ // ═══════════════════════════════════════════
288
+ // TEXT CLEANING (Strip page noise before sending to AI)
289
+ // ═══════════════════════════════════════════
290
+ function cleanExtractedText(raw) {
291
+ if (!raw) return raw;
292
+
293
+ const lines = raw.split('\n');
294
+ let cleaned = [];
295
+ let hitCutoff = false;
296
+
297
+ // Patterns that signal "end of real question content" (less strict about line start)
298
+ const CUTOFF_PATTERNS = [
299
+ /discussion\s*\(/i,
300
+ /similar questions/i,
301
+ /comments?$/i,
302
+ /sort by/i,
303
+ /choose a type/i,
304
+ /copyright/i,
305
+ /daily question tag/i,
306
+ /\d+ days? badge/i,
307
+ ];
308
+
309
+ // Lines to always skip (Boilerplate UI Noise)
310
+ const SKIP_PATTERNS = [
311
+ /^(back|forward|reload|extensions|bookmark|new tab|mute tab|restore)$/i,
312
+ /^address and search bar|search tabs|tab content shared|memory usage$/i,
313
+ /^view site information|control your music$/i,
314
+ /^install app|installing\.\.\.$/i, // Specific: Won't match "Install nginx"
315
+ /^(prev question|next question|pick one|expand panel|upgrade to premium)$/i,
316
+ /^(ask leet|layouts|settings|stopwatch|invite|user menu|premium lock)$/i,
317
+ /^(leetcode logo|online|saved|ln \d+|col \d+)$/i,
318
+ /^\d+ minutes?.*seconds?$/i,
319
+ /^(accepted|acceptance rate|seen this question)$/i,
320
+ /^(hint \d|topics|companies)$/i,
321
+ /^\w+\s+(easy|med\.|medium|hard)$/i,
322
+ /^\d+\.\s+\w+.*\s+(easy|med\.|medium|hard)$/i,
323
+ ];
324
+
325
+ // SECOND PASS: Extract code editor template from FULL text (priority)
326
+ const codePatterns = [
327
+ /class\s+Solution[\s\S]*?\{[\s\S]*?\};?/, // LeetCode C++/Java Class
328
+ /def\s+\w+\(self[\s\S]*?\):/, // Python
329
+ /function\s+\w+\([\s\S]*?\)\s*\{/, // JS
330
+ /public\s+[\s\S]*?class\s+\w+[\s\S]*?\{/, // General Java
331
+ ];
332
+
333
+ let template = "";
334
+ for (const pat of codePatterns) {
335
+ const match = raw.match(pat);
336
+ if (match) { template = match[0].trim(); break; }
337
+ }
338
+
339
+ for (const line of lines) {
340
+ const trimmed = line.trim();
341
+ if (!trimmed) continue;
342
+
343
+ // Check cutoff
344
+ for (const pat of CUTOFF_PATTERNS) {
345
+ if (pat.test(trimmed)) { hitCutoff = true; break; }
346
+ }
347
+ if (hitCutoff) break;
348
+
349
+ // Check skip
350
+ let skip = false;
351
+ for (const pat of SKIP_PATTERNS) {
352
+ if (pat.test(trimmed)) { skip = true; break; }
353
+ }
354
+ if (skip) continue;
355
+
356
+ cleaned.push(trimmed);
357
+ }
358
+
359
+ // Cap description at 8000 chars for modern LLMs
360
+ let description = cleaned.join('\n');
361
+ if (description.length > 8000) {
362
+ description = description.substring(0, 8000) + '\n[...Description Truncated...]';
363
+ }
364
+
365
+ // Final assembly: Template FIRST so AI definitely sees what function to fix
366
+ let final = "";
367
+ if (template) final += "--- CODE TEMPLATE (DO NOT CHANGE SIGNATURE) ---\n" + template + "\n\n";
368
+ final += "--- PROBLEM DESCRIPTION ---\n" + description;
369
+
370
+ return final;
371
+ }
372
+
373
+ async function captureTextQuestion() {
374
+ if (batchQueue.length >= 10) return;
375
+ console.log(`[CAPTURE] Using Standalone UIA Engine (.exe)...`);
376
+
377
+ // Call the compiled executable (zero-dependency, skips Electron windows)
378
+ const exePath = path.join(__dirname, 'bin', 'uia_extract.exe');
379
+ const cmd = `"${exePath}"`;
380
+
381
+ // Ensure no terminal pops up and steals focus
382
+ exec(cmd, { encoding: 'utf8', windowsHide: true }, (error, stdout, stderr) => {
383
+ if (error) {
384
+ console.error(`[UIA] Engine Error: ${error.message}`);
385
+ return;
386
+ }
387
+ const rawText = stdout.trim();
388
+ const text = cleanExtractedText(rawText);
389
+ if (text && !text.startsWith("ERROR") && !text.startsWith("TARGET:")) {
390
+ batchQueue.push({ img: null, text: text, time: Date.now() });
391
+ console.log(`[QUEUE] Added text question ${batchQueue.length}/10 (${text.length} chars, cleaned from ${rawText.length})`);
392
+ updateUI();
393
+ } else {
394
+ console.warn(`[UIA] No text extracted or fallback only: ${text}`);
395
+ if (overlayWindow) overlayWindow.webContents.send('update-ans', '⚠️ NO TEXT DETECTED (USE IMAGE CAPTURE)');
396
+ }
397
+ });
398
+ }
399
+
400
+ async function performOracleStrike() {
401
+ if (batchQueue.length === 0) return;
402
+
403
+ console.log(`[STRIKE] Sending ${batchQueue.length} questions to ChatGPT...`);
404
+
405
+ const images = batchQueue.filter(q => q.img).map(item => item.img);
406
+ const textContext = batchQueue.filter(q => q.text).map(item => item.text).join('\n\n───\n\n');
407
+
408
+ // Build the correct prompt based on section
409
+ const finalPrompt = SECTION_PROMPTS[activeSection] || SYSTEM_PROMPT;
410
+
411
+ // Preparation Script
412
+ const injectionScript = `
413
+ (async function() {
414
+ try {
415
+ const imgs = ${JSON.stringify(images)};
416
+ const texts = ${JSON.stringify(textContext)};
417
+ const PROMPT = ${JSON.stringify(finalPrompt)};
418
+
419
+ const input = document.querySelector('div[contenteditable="true"]') ||
420
+ document.querySelector('textarea') ||
421
+ document.querySelector('.ProseMirror') ||
422
+ document.querySelector('[aria-label*="message"]');
423
+ if (!input) return "Input Not Found";
424
+
425
+ input.focus();
426
+
427
+ // 1. Paste Images if any
428
+ for (const dataUrl of imgs) {
429
+ const parts = dataUrl.split(',');
430
+ const bstr = atob(parts[1]);
431
+ let n = bstr.length;
432
+ const u8arr = new Uint8Array(n);
433
+ while(n--) u8arr[n] = bstr.charCodeAt(n);
434
+ const file = new File([u8arr], "question.png", { type: "image/png" });
435
+ const dt = new DataTransfer();
436
+ dt.items.add(file);
437
+ const pasteEvent = new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true });
438
+ input.dispatchEvent(pasteEvent);
439
+ await new Promise(r => setTimeout(r, 800));
440
+ }
441
+
442
+ // 2. Insert Accumulated Text Context
443
+ if (texts) {
444
+ document.execCommand('insertText', false, "CONTEXT FROM UIA:\\n" + texts + "\\n\\n");
445
+ input.dispatchEvent(new Event('input', { bubbles: true }));
446
+ }
447
+
448
+ // 3. Dynamic User-Controlled Prompt
449
+ document.execCommand('insertText', false, PROMPT);
450
+ input.dispatchEvent(new Event('input', { bubbles: true }));
451
+
452
+ // ☢️ STATE FORCE: Make React/ProseMirror recognize our text
453
+ input.dispatchEvent(new Event('input', { bubbles: true }));
454
+ input.dispatchEvent(new Event('change', { bubbles: true }));
455
+
456
+ // 🎯 WAIT for Send button to become active, THEN press Enter
457
+ let attempts = 0;
458
+ while (attempts < 50) {
459
+ await new Promise(r => setTimeout(r, 200));
460
+
461
+ const sendBtn = document.querySelector('button[data-testid="send-button"]') ||
462
+ document.querySelector('button[aria-label*="Send"]');
463
+
464
+ if (sendBtn && !sendBtn.disabled) {
465
+ // Button is ready — fire Enter
466
+ const enterDown = new KeyboardEvent('keydown', {
467
+ key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
468
+ bubbles: true, cancelable: true
469
+ });
470
+ const enterPress = new KeyboardEvent('keypress', {
471
+ key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
472
+ bubbles: true, cancelable: true
473
+ });
474
+ const enterUp = new KeyboardEvent('keyup', {
475
+ key: 'Enter', code: 'Enter', keyCode: 13, which: 13,
476
+ bubbles: true, cancelable: true
477
+ });
478
+
479
+ input.focus();
480
+ input.dispatchEvent(enterDown);
481
+ input.dispatchEvent(enterPress);
482
+ input.dispatchEvent(enterUp);
483
+
484
+ return "Success (Enter after " + (attempts * 200) + "ms)";
485
+ }
486
+ attempts++;
487
+ }
488
+ return "Timeout - Send never activated";
489
+ } catch (err) { return "Error: " + err.message; }
490
+ })()
491
+ `;
492
+
493
+ if (chatgptWin) {
494
+ chatgptWin.webContents.executeJavaScript(injectionScript)
495
+ .then(result => console.log("[STRIKE] Script Result:", result))
496
+ .catch(err => console.error("[STRIKE ERROR] Failed to execute injection:", err));
497
+
498
+ pollForResult(chatgptWin, 'chatgpt');
499
+ promptSent = true;
500
+ }
501
+
502
+ // Increment question counter by batch size for accurate history tracking
503
+ const batchSize = batchQueue.length;
504
+ const startQ = questionCounter + 1;
505
+ const endQ = questionCounter + batchSize;
506
+ questionCounter = endQ;
507
+
508
+ const solveTag = batchSize > 1 ? `[Q${startQ}-${endQ}]` : `[Q${startQ}]`;
509
+ overlayWindow.webContents.send('update-ans', JSON.stringify({ type: 'solving', qNum: solveTag }));
510
+
511
+ batchQueue = [];
512
+ updateUI();
513
+ }
514
+
515
+ let sessionHistory = []; // [{qNum: 1, answer: "Option B"}, ...]
516
+ let questionCounter = 0;
517
+ let lastPollHash = "";
518
+
519
+ let pollInterval = null;
520
+ async function pollForResult(win) {
521
+ if (pollInterval) clearTimeout(pollInterval);
522
+
523
+ // Grab ALL assistant response texts
524
+ const pollScript = `
525
+ (function() {
526
+ try {
527
+ // Target the specific assistant message content blocks
528
+ const assistantMsgs = document.querySelectorAll('[data-message-author-role="assistant"]');
529
+ const results = [];
530
+
531
+ assistantMsgs.forEach(msg => {
532
+ // Try to find the inner prose/markdown content first (cleanest)
533
+ const content = msg.querySelector('.prose, .markdown') || msg;
534
+ const text = content.innerText.trim();
535
+ if (text && text.length > 3 && text !== "Thinking...") {
536
+ results.push(text);
537
+ }
538
+ });
539
+
540
+ // Final safety: Remove identical consecutive duplicates
541
+ return JSON.stringify(results.filter((item, pos, self) => {
542
+ return !pos || item !== self[pos - 1];
543
+ }));
544
+ } catch(e) { return null; }
545
+ })()
546
+ `;
547
+
548
+ async function runPoll() {
549
+ if (!win || win.isDestroyed()) return;
550
+ try {
551
+ const result = await win.webContents.executeJavaScript(pollScript);
552
+ if (result) {
553
+ const allAnswers = JSON.parse(result);
554
+ // Include total count and last message hash for streaming/history refresh
555
+ const lastIdx = allAnswers.length - 1;
556
+ const lastText = lastIdx >= 0 ? allAnswers[lastIdx] : "";
557
+ const hash = allAnswers.length + ':' + lastText.length + ':' + lastText.substring(0, 20);
558
+
559
+ if (hash !== lastPollHash && allAnswers.length > 0) {
560
+ lastPollHash = hash;
561
+
562
+ // Update persistent sessionHistory: Map every assistant message to a question block
563
+ // Note: If multiple questions were in one batch, they might be inside a single message block
564
+ sessionHistory = allAnswers.map((ans, i) => ({
565
+ qNum: i + 1,
566
+ answer: ans.replace(/\n+$/, '').trim()
567
+ }));
568
+
569
+ if (overlayWindow && !overlayWindow.isDestroyed()) {
570
+ overlayWindow.webContents.send('update-ans', JSON.stringify({ type: 'history', items: sessionHistory }));
571
+ updateUI();
572
+ }
573
+ }
574
+ }
575
+ } catch (e) {}
576
+ pollInterval = setTimeout(runPoll, 500);
577
+ }
578
+
579
+ runPoll();
580
+ }
581
+
582
+ // ═══════════════════════════════════════════
583
+ // UI DISPATCH & HUD
584
+ // ═══════════════════════════════════════════
585
+
586
+ function updateUI() {
587
+ if (!overlayWindow) return;
588
+ overlayWindow.webContents.send('update-hud', {
589
+ count: batchQueue.length,
590
+ isForcedHidden,
591
+ isUiHidden,
592
+ isPinned,
593
+ isAlwaysOnTop,
594
+ isCombatMode,
595
+ activeSection
596
+ });
597
+ if (sessionHistory.length > 0) {
598
+ overlayWindow.webContents.send('update-ans', JSON.stringify({ type: 'history', items: sessionHistory }));
599
+ }
600
+ }
601
+
602
+ // ═══════════════════════════════════════════
603
+ // STEALTH POLLING (Hover Reveal)
604
+ // ═══════════════════════════════════════════
605
+ // ═══════════════════════════════════════════
606
+ // STEALTH ENGINE (Edges & Jitter)
607
+ // ═══════════════════════════════════════════
608
+ setInterval(() => {
609
+ if (!overlayWindow || overlayWindow.isDestroyed()) return;
610
+
611
+ const mouse = screen.getCursorScreenPoint();
612
+ const { width: screenWidth, height: screenHeight } = screen.getPrimaryDisplay().bounds;
613
+
614
+ // 1. Edge Triggers (Capture/Solve)
615
+ if (Date.now() > edgeCooldown) {
616
+ if (mouse.x >= screenWidth - 1) { // Right Edge Proximity
617
+ if (!edgeActive.right) {
618
+ captureTextQuestion();
619
+ edgeActive.right = true;
620
+ edgeCooldown = Date.now() + 2000; // 2s cooldown
621
+ }
622
+ } else {
623
+ edgeActive.right = false;
624
+ }
625
+
626
+ if (mouse.x <= 0) { // Left Edge Proximity
627
+ if (!edgeActive.left) {
628
+ performOracleStrike();
629
+ edgeActive.left = true;
630
+ edgeCooldown = Date.now() + 2000;
631
+ }
632
+ } else {
633
+ edgeActive.left = false;
634
+ }
635
+ }
636
+
637
+ lastMousePos = { x: mouse.x, y: mouse.y };
638
+
639
+ // 3. Position HUD Window
640
+ if (isPinned) return;
641
+
642
+ if (isForcedHidden) {
643
+ if (wasVisible) {
644
+ overlayWindow.hide();
645
+ wasVisible = false;
646
+ }
647
+ } else {
648
+ if (!wasVisible) {
649
+ overlayWindow.showInactive();
650
+ wasVisible = true;
651
+ }
652
+
653
+ const sf = screen.getPrimaryDisplay().scaleFactor || 1.0;
654
+ overlayWindow.setBounds({
655
+ x: Math.round(mouse.x + 10), y: Math.round(mouse.y + 10),
656
+ width: Math.round(300 * sf), height: Math.round(150 * sf)
657
+ });
658
+ }
659
+ }, 25);
660
+
661
+ // ═══════════════════════════════════════════
662
+ // HOTKEYS
663
+ // ═══════════════════════════════════════════
664
+
665
+ app.whenReady().then(async () => {
666
+ app.setName('Windows Diagnostic Utility');
667
+
668
+ // 🛡️ FIREWALL SHIELD: Apply Proxy if specified
669
+ if (PROXY_RULE) {
670
+ console.log(`[PROXY] Routing traffic through: ${PROXY_RULE}`);
671
+ const proxyConfig = { proxyRules: PROXY_RULE };
672
+ await session.defaultSession.setProxy(proxyConfig);
673
+ const gptSess = session.fromPartition('persist:chatgpt');
674
+ await gptSess.setProxy(proxyConfig);
675
+ }
676
+
677
+ createOverlayWindow();
678
+ chatgptWin = createBridge('chatgpt', 'https://chat.openai.com', 'chatgpt');
679
+
680
+ // Run environment check after windows are ready
681
+ setTimeout(checkEnvironment, 2000);
682
+
683
+ const register = (key, fn) => {
684
+ const success = globalShortcut.register(key, fn);
685
+ console.log(`[KEY] ${key} registration: ${success ? 'OK' : 'FAILED'}`);
686
+ return success;
687
+ };
688
+
689
+ // 🎯 HOTKEYS: Only keep Alt+X and Alt+C
690
+ register('Alt+C', () => {
691
+ isCombatMode = !isCombatMode;
692
+ updateUI();
693
+ console.log(`[APP] Combat Mode (Lex200 Defense): ${isCombatMode}`);
694
+ });
695
+
696
+ register('Alt+X', () => {
697
+ if (isCombatMode) return;
698
+ isAdminVisible = !isAdminVisible;
699
+ if (chatgptWin) {
700
+ if (isAdminVisible) {
701
+ const { width, height } = screen.getPrimaryDisplay().workAreaSize;
702
+ chatgptWin.setOpacity(1.0);
703
+ chatgptWin.setBounds({
704
+ x: Math.round(width/2 - 550),
705
+ y: Math.round(height/2 - 425),
706
+ width: 1100, height: 850
707
+ });
708
+ chatgptWin.focus();
709
+ } else {
710
+ chatgptWin.setOpacity(0.01);
711
+ chatgptWin.setBounds({ x: -10000, y: -10000, width: 1100, height: 850 });
712
+ }
713
+ }
714
+ });
715
+
716
+ // 🕊️ GHOST MODE: uIOhook Listener (Arrow Keys only)
717
+ let isUpPressed = false, isDownPressed = false, isLeftPressed = false, isRightPressed = false;
718
+ let isShiftPressed = false;
719
+ let isChordLocked = false;
720
+
721
+ uIOhook.on('keydown', (e) => {
722
+ // Wrap in setImmediate to prevent N-API thread crash
723
+ setImmediate(() => {
724
+ if (e.keycode === 57416 || e.keycode === 72) isUpPressed = true;
725
+ if (e.keycode === 57424 || e.keycode === 80) isDownPressed = true;
726
+ if (e.keycode === 57419 || e.keycode === 75) isLeftPressed = true;
727
+ if (e.keycode === 57421 || e.keycode === 77) isRightPressed = true;
728
+ if (e.keycode === 42 || e.keycode === 54) isShiftPressed = true;
729
+
730
+ // 1. Hide/Unhide HUD (Up + Down)
731
+ if (isUpPressed && isDownPressed) {
732
+ isForcedHidden = !isForcedHidden;
733
+ updateUI();
734
+ isUpPressed = false; isDownPressed = false;
735
+ }
736
+
737
+ // 3. TEXT CAPTURE (Left + Right) — 100% Safe
738
+ if (isLeftPressed && isRightPressed) {
739
+ if (isChordLocked) return;
740
+ console.log(`[CHORD] TEXT CAPTURE Triggered (Safe Mode)...`);
741
+ isChordLocked = true;
742
+ captureTextQuestion();
743
+ isLeftPressed = false; isRightPressed = false;
744
+ setTimeout(() => { isChordLocked = false; }, 2000);
745
+ }
746
+
747
+ // 3b. IMAGE CAPTURE (Down + Left) — Diagram Mode
748
+ if (isDownPressed && isLeftPressed) {
749
+ if (isChordLocked) return;
750
+ console.log(`[CHORD] DIAGRAM CAPTURE Triggered (GDI Mode)...`);
751
+ isChordLocked = true;
752
+ captureImageQuestion();
753
+ isDownPressed = false; isLeftPressed = false;
754
+ setTimeout(() => { isChordLocked = false; }, 2000);
755
+ }
756
+
757
+ // 4. Perform Strike (Up + Right)
758
+ if (isUpPressed && isRightPressed) {
759
+ performOracleStrike();
760
+ isUpPressed = false; isRightPressed = false;
761
+ }
762
+
763
+ // 5. Pin/Unpin (Up + Left)
764
+ if (isUpPressed && isLeftPressed) {
765
+ isPinned = !isPinned;
766
+ updateUI();
767
+ isUpPressed = false; isLeftPressed = false;
768
+ }
769
+ });
770
+ });
771
+
772
+ uIOhook.on('keyup', (e) => {
773
+ setImmediate(() => {
774
+ if (e.keycode === 57416 || e.keycode === 72) isUpPressed = false;
775
+ if (e.keycode === 57424 || e.keycode === 80) isDownPressed = false;
776
+ if (e.keycode === 57419 || e.keycode === 75) isLeftPressed = false;
777
+ if (e.keycode === 57421 || e.keycode === 77) isRightPressed = false;
778
+ if (e.keycode === 42 || e.keycode === 54) isShiftPressed = false;
779
+ });
780
+ });
781
+
782
+ // STEALTH CLICK HANDLER: Manually route clicks when window is focusable:false
783
+ uIOhook.on('mousedown', (e) => {
784
+ setImmediate(() => {
785
+ if (!overlayWindow || overlayWindow.isDestroyed() || !overlayWindow.isVisible()) return;
786
+ const bounds = overlayWindow.getBounds();
787
+ const primaryDisplay = screen.getPrimaryDisplay();
788
+ const sf = primaryDisplay.scaleFactor;
789
+
790
+ const mX = e.x / sf;
791
+ const mY = e.y / sf;
792
+
793
+ if (mX >= bounds.x && mX <= bounds.x + bounds.width &&
794
+ mY >= bounds.y && mY <= bounds.y + bounds.height) {
795
+ const clientX = Math.round(mX - bounds.x);
796
+ const clientY = Math.round(mY - bounds.y);
797
+ overlayWindow.webContents.send('stealth-click', { x: clientX, y: clientY });
798
+ }
799
+ });
800
+ });
801
+
802
+ // (Manual wheel listener removed to allow native touchpad support)
803
+
804
+ // Delay start to let Electron event loop stabilize
805
+ setTimeout(() => {
806
+ uIOhook.start();
807
+ console.log('[GHOST] uIOhook started successfully.');
808
+ }, 500);
809
+
810
+ // ☢️ DECONTAMINATION PROTOCOL (Alt + Shift + X)
811
+ register('Alt+Shift+X', async () => {
812
+ console.log("☢️ SELF-DESTRUCT INITIATED...");
813
+ const burnScript = `
814
+ (async function() {
815
+ try {
816
+ const gptDelete = document.querySelector('nav .bg-red-500') || document.querySelector('[aria-label*="Delete"]');
817
+ if (gptDelete) gptDelete.click();
818
+ await new Promise(r => setTimeout(r, 500));
819
+ } catch(e) {}
820
+ })()
821
+ `;
822
+ if (chatgptWin) {
823
+ chatgptWin.webContents.executeJavaScript(burnScript).catch(e => {});
824
+ await chatgptWin.webContents.session.clearStorageData();
825
+ }
826
+ promptSent = false;
827
+ await session.defaultSession.clearStorageData();
828
+ console.log("☢️ WIPE COMPLETE. EXITING.");
829
+ app.exit(0);
830
+ });
831
+
832
+ // (Double-click pin handler removed)
833
+ });