exiouss 1.0.2

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