Advertisement
NashrifZMgs

TVremote

Jun 12th, 2025 (edited)
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Universal On-Screen Console & Pointer (v71 - Final Tuner Fix)
  3. // @namespace    https://viayoo.com
  4. // @version      2025-06-27.71
  5. // @description  Final Production Build. Fixed a bug where the speed tuner (key 5) could not be hidden after being shown. All features are stable.
  6. // @author       Gemini & Vyacheslav
  7. // @match        *://*/*
  8. // @grant        none
  9. // @run-at       document-start
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     // ===================================================================================
  16.     // --- PART 1: IMMEDIATE HIJACK (Stable) ---
  17.     // ===================================================================================
  18.     let logBuffer = []; let uiReady = false; let _renderLogs = () => {};
  19.     let _showCustomDialog = () => {};
  20.     const originalConsole = { log: console.log, error: console.error, warn: console.warn, info: console.info, debug: console.debug };
  21.  
  22.     window.alert = (message) => { if(uiReady) _showCustomDialog({ type: 'alert', message }); };
  23.     window.confirm = (message) => { return new Promise(resolve => uiReady ? _showCustomDialog({ type: 'confirm', message, resolve }) : resolve(false)); };
  24.     window.prompt = (message, defaultValue = '') => { return new Promise(resolve => uiReady ? _showCustomDialog({ type: 'prompt', message, defaultValue, resolve }) : resolve(null)); };
  25.  
  26.     const hijack = (type, color) => { console[type] = function(...args) { let isFromPointerScript = args.length > 0 && args[args.length - 1] && args[args.length - 1].__fromPointerScript === true; if (isFromPointerScript) args.pop(); const source = isFromPointerScript ? 'script' : 'external'; const message = args.map(arg => { try { if (arg instanceof Error) return arg.stack || arg.message; if (arg && typeof arg === 'object') return JSON.stringify(arg); return String(arg); } catch (e) { return '[Unserializable Object]'; } }).join(' '); logBuffer.push({ message: `[${type.toUpperCase()}] ${message}`, color, source, timestamp: Date.now() }); if (logBuffer.length > 250) logBuffer.shift(); if (uiReady) { _renderLogs(); } if (originalConsole[type]) { originalConsole[type].apply(console, args); } }; };
  27.     hijack('log', '#FFFFFF'); hijack('warn', '#FFD700'); hijack('error', '#FF6B6B'); hijack('info', '#61AFEF'); hijack('debug', '#BE50F4');
  28.     window.addEventListener('error', (e) => { console.error(`Uncaught: ${e.message} at ${e.filename}:${e.lineno}`); });
  29.     window.addEventListener('unhandledrejection', (e) => { console.error('Promise Rejection:', e.reason); });
  30.  
  31.     // ===================================================================================
  32.     // --- PART 2: UI AND SCRIPT INITIALIZATION ---
  33.     // ===================================================================================
  34.     function initializeScript() {
  35.         let debugConsole, consoleContent, scriptModeButton, allModeButton, tunerUI, tunerValueElement, consoleInputElement, pointer, modalOverlay;
  36.         let consoleIsVisible = false, consoleDisplayMode = 'script', tunerIsVisible = false;
  37.         let scriptActive, currentMode, isDragging, enterHoldStartTime, dragTarget, textInputMode, scrollTarget, escapeKeyPressed, currentPointerStyleIndex;
  38.         const cursor = { x: window.innerWidth / 2, y: window.innerHeight / 2 }; const keysDown = {}; let lastFrameTime = performance.now();
  39.         const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
  40.         const SETTINGS = { POINTER_INITIAL_SPEED: 150, POINTER_TOP_SPEED: 900, POINTER_ACCELERATION_TIME: 800, CURSOR_SIZE: 24, ENTER_HOLD_THRESHOLD: 220, SCROLL_SPEED_INITIAL: 8, SCROLL_SPEED_MAX: 40, SCROLL_ACCELERATION_TIME: 1200, };
  41.         const COLORS = { NORMAL: 'black', SCROLL: '#0EA5E9' };
  42.         const POINTER_STYLES = [ { width: `${SETTINGS.CURSOR_SIZE}px`, height: `${SETTINGS.CURSOR_SIZE}px`, backgroundColor: 'rgba(255, 255, 255, 0.5)', border: '3px solid', baseBorderColor: COLORS.NORMAL, borderRadius: '50%', boxShadow: '0 2px 5px rgba(0,0,0,0.5)' }, { width: '12px', height: '12px', backgroundColor: 'rgba(255, 20, 20, 0.9)', border: '1px solid', baseBorderColor: 'rgba(255, 255, 255, 0.8)', borderRadius: '50%', boxShadow: '0 0 5px red' }, ];
  43.        
  44.         const scriptConsole = { info: (message) => console.info(message, { __fromPointerScript: true }) };
  45.  
  46.         function renderLogs() { if (!consoleContent) return; consoleContent.innerHTML = ''; const f = logBuffer.filter(l=>consoleDisplayMode==='all'||l.source==='script'); f.forEach(l=>{const e=document.createElement('div');e.textContent=l.message.startsWith('>') ? l.message : ` ${l.message}`;e.style.color=l.color;e.style.borderBottom='1px solid #333';e.style.padding='2px 5px';e.style.fontFamily='monospace';if(l.source==='external')e.style.opacity='0.7';consoleContent.appendChild(e);}); consoleContent.scrollTop = consoleContent.scrollHeight; }
  47.         _renderLogs = renderLogs;
  48.        
  49.         function createDebugUI() {
  50.             if(document.getElementById('gm-debug-console'))return;
  51.             debugConsole=document.createElement('div');debugConsole.id='gm-debug-console';Object.assign(debugConsole.style,{position:'fixed',top:'10px',left:'10px',width:'calc(100% - 20px)',maxWidth:'800px',maxHeight:'50vh',backgroundColor:'rgba(20,20,20,0.95)',color:'white',fontFamily:'monospace',fontSize:'13px',zIndex:'2147483647',border:'1px solid #555',display:'none',flexDirection:'column',boxShadow:'0 5px 15px rgba(0,0,0,0.5)'});
  52.             const h=document.createElement('div');Object.assign(h.style,{padding:'8px',borderBottom:'1px solid #444',display:'flex',gap:'10px',alignItems:'center',backgroundColor:'rgba(40,40,40,0.9)'});
  53.             scriptModeButton=document.createElement('button');scriptModeButton.textContent='Script Logs';allModeButton=document.createElement('button');allModeButton.textContent='All Logs';
  54.             [scriptModeButton,allModeButton].forEach(b=>{Object.assign(b.style,{background:'transparent',border:'1px solid #718096',color:'white',padding:'4px 10px',borderRadius:'4px',cursor:'pointer',fontFamily:'sans-serif',fontSize:'12px'});h.appendChild(b);});
  55.             scriptModeButton.addEventListener('click',e=>{e.stopPropagation();consoleDisplayMode='script';updateConsoleModeButtons();renderLogs();});
  56.             allModeButton.addEventListener('click',e=>{e.stopPropagation();consoleDisplayMode='all';updateConsoleModeButtons();renderLogs();});
  57.             consoleContent=document.createElement('div');Object.assign(consoleContent.style,{padding:'8px',overflowY:'scroll',flexGrow:'1',wordWrap:'break-word',whiteSpace:'pre-wrap'});
  58.             const consoleInputWrapper = document.createElement('div');
  59.             Object.assign(consoleInputWrapper.style, { display: 'flex', alignItems: 'center', padding: '4px 8px', borderTop: '1px solid #444', backgroundColor: 'rgba(0,0,0,0.3)' });
  60.             const prompt = document.createElement('span');prompt.textContent = '>';Object.assign(prompt.style, { marginRight: '8px', color: '#61AFEF', userSelect:'none' });
  61.             consoleInputElement = document.createElement('input');consoleInputElement.id = 'gm-console-input'; consoleInputElement.type = 'text';consoleInputElement.placeholder = 'Click to activate...';
  62.             Object.assign(consoleInputElement.style, { flexGrow: '1', background: 'transparent', border: 'none', color: 'white', fontFamily: 'monospace', fontSize: '14px', outline: 'none' });
  63.  
  64.             consoleInputElement.addEventListener('keydown', async (e) => {
  65.                 if (e.key === 'Enter') {
  66.                     e.preventDefault(); const command = consoleInputElement.value.trim(); if (!command) return;
  67.                     consoleInputElement.placeholder = 'Execute JavaScript...';
  68.                     logBuffer.push({ message: `> ${command}`, color: '#FFFFFF', source: 'script', timestamp: Date.now() });
  69.                     renderLogs();
  70.                     try { const executor = new AsyncFunction(command); const result = await executor.call(window); if (result !== undefined) { const resultString = JSON.stringify(result, null, 2); logBuffer.push({ message: `⇐ ${resultString}`, color: '#BE50F4', source: 'script', timestamp: Date.now() }); }
  71.                     } catch (error) { logBuffer.push({ message: `[EXECUTION ERROR] ${error.stack || error.message}`, color: '#FF6B6B', source: 'script', timestamp: Date.now() }); }
  72.                     consoleInputElement.value = ''; renderLogs();
  73.                     exitTextInputMode(true);
  74.                 }
  75.             });
  76.  
  77.             consoleInputWrapper.appendChild(prompt); consoleInputWrapper.appendChild(consoleInputElement);
  78.             debugConsole.appendChild(h); debugConsole.appendChild(consoleContent); debugConsole.appendChild(consoleInputWrapper);
  79.             document.body.appendChild(debugConsole);
  80.         };
  81.        
  82.         function createModalOverlay() { if (document.getElementById('gm-modal-overlay')) return; modalOverlay = document.createElement('div'); modalOverlay.id = 'gm-modal-overlay'; Object.assign(modalOverlay.style, { position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh', zIndex: '2147483648', display: 'none', justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0,0,0,0.6)'}); document.body.appendChild(modalOverlay); }
  83.        
  84.         function showCustomDialog({ type, message, defaultValue, resolve }) {
  85.             modalOverlay.innerHTML = '';
  86.             modalOverlay.appendChild(pointer);
  87.             const dialog = document.createElement('div');
  88.             Object.assign(dialog.style, { background: '#2d3748', color: 'white', padding: '20px', borderRadius: '8px', boxShadow: '0 5px 20px rgba(0,0,0,0.4)', border: '1px solid #4A5568', minWidth: '300px', maxWidth: '500px', zIndex: '1' });
  89.             const messageEl = document.createElement('p');
  90.             messageEl.textContent = message;
  91.             Object.assign(messageEl.style, { margin: '0 0 15px 0', whiteSpace: 'pre-wrap', wordWrap: 'break-word' });
  92.             dialog.appendChild(messageEl);
  93.             let inputEl, okButton, cancelButton;
  94.             const buttonContainer = document.createElement('div');
  95.             Object.assign(buttonContainer.style, { display: 'flex', justifyContent: 'flex-end', gap: '10px', marginTop: '10px' });
  96.             const cleanup = () => { modalOverlay.style.display = 'none'; document.body.appendChild(pointer); if (textInputMode && document.activeElement && document.activeElement.id.startsWith('gm-dialog-input')) { exitTextInputMode(true); } };
  97.             okButton = document.createElement('button'); okButton.textContent = 'OK'; okButton.id = `gm-dialog-ok-${Date.now()}`;
  98.             Object.assign(okButton.style, { padding: '8px 16px', border: 'none', borderRadius: '4px', cursor: 'pointer', background: '#3182CE' });
  99.             if (type === 'prompt') {
  100.                 inputEl = document.createElement('input'); inputEl.id = `gm-dialog-input-${Date.now()}`;
  101.                 Object.assign(inputEl.style, { width: 'calc(100% - 20px)', padding: '8px', background: '#1A202C', border: '1px solid #4A5568', borderRadius: '4px', color: 'white', marginBottom: '10px' });
  102.                 inputEl.value = defaultValue || '';
  103.                 dialog.appendChild(inputEl);
  104.             }
  105.             if (type === 'confirm' || type === 'prompt') {
  106.                 cancelButton = document.createElement('button'); cancelButton.textContent = 'Cancel';
  107.                 cancelButton.id = `gm-dialog-cancel-${Date.now()}`;
  108.                 Object.assign(cancelButton.style, { padding: '8px 16px', border: 'none', borderRadius: '4px', cursor: 'pointer', background: '#4A5568' });
  109.                 buttonContainer.appendChild(cancelButton);
  110.             }
  111.             buttonContainer.appendChild(okButton);
  112.             dialog.appendChild(buttonContainer);
  113.             modalOverlay.appendChild(dialog);
  114.             okButton.addEventListener('click', () => { if (type === 'prompt') resolve(inputEl.value); else if (type === 'confirm') resolve(true); cleanup(); });
  115.             if (cancelButton) { cancelButton.addEventListener('click', () => { if (type === 'prompt') resolve(null); else if (type === 'confirm') resolve(false); cleanup(); }); }
  116.             if (type === 'alert') { const t = setTimeout(cleanup, 7000); okButton.addEventListener('click', () => clearTimeout(t)); }
  117.             modalOverlay.style.display = 'flex';
  118.             if (type === 'prompt') { textInputMode = true; inputEl.focus(); }
  119.         }
  120.         _showCustomDialog = showCustomDialog;
  121.  
  122.         const updateConsoleModeButtons = () => { if (!scriptModeButton || !allModeButton) return; const a={backgroundColor:'#4A5568',borderColor:'#A0AEC0'},i={backgroundColor:'transparent',borderColor:'#718096'};Object.assign(scriptModeButton.style,consoleDisplayMode==='script'?a:i);Object.assign(allModeButton.style,consoleDisplayMode==='all'?a:i); };
  123.         const toggleConsole = () => { consoleIsVisible = !consoleIsVisible; if (debugConsole) { debugConsole.style.display = consoleIsVisible ? 'flex' : 'none'; } if (consoleIsVisible) { renderLogs(); } };
  124.         function createTunerUI() { if(document.getElementById('gm-tuner-ui'))return;tunerUI=document.createElement('div');tunerUI.id='gm-tuner-ui';Object.assign(tunerUI.style,{position:'fixed',top:'20px',left:'50%',transform:'translateX(-50%)',display:'none',alignItems:'center',gap:'20px',backgroundColor:'rgba(0,0,0,0.7)',color:'white',fontFamily:'sans-serif',padding:'10px 20px',borderRadius:'8px',zIndex:'2147483647',border:'1px solid #555'});const l=document.createElement('div');l.textContent='<';const r=document.createElement('div');r.textContent='>';tunerValueElement=document.createElement('div');[l,r].forEach(a=>Object.assign(a.style,{fontSize:'24px',fontWeight:'bold',cursor:'pointer'}));Object.assign(tunerValueElement.style,{fontSize:'18px',minWidth:'80px',textAlign:'center'});tunerUI.appendChild(l);tunerUI.appendChild(tunerValueElement);tunerUI.appendChild(r);document.body.appendChild(tunerUI);}
  125.         const toggleTuner = () => { tunerIsVisible = !tunerIsVisible; if (tunerUI) tunerUI.style.display = tunerIsVisible ? 'flex' : 'none'; };
  126.         function saveState() { sessionStorage.setItem('gm-pointer-active', JSON.stringify(scriptActive)); sessionStorage.setItem('gm-console-visible', JSON.stringify(consoleIsVisible)); if(consoleIsVisible) { sessionStorage.setItem('gm-console-logs', JSON.stringify(logBuffer)); sessionStorage.setItem('gm-console-mode', consoleDisplayMode); } }
  127.         function loadState() { const wasPointerActive = sessionStorage.getItem('gm-pointer-active'); scriptActive = wasPointerActive === null ? true : JSON.parse(wasPointerActive); const wasConsoleVisible = sessionStorage.getItem('gm-console-visible') === 'true'; if (wasConsoleVisible) { consoleIsVisible = true; const savedLogs = sessionStorage.getItem('gm-console-logs'); if (savedLogs) { try { const parsedLogs = JSON.parse(savedLogs); if (Array.isArray(parsedLogs)) { logBuffer.splice(0, 0, ...parsedLogs); } } catch(e) { /* ignore */ } } consoleDisplayMode = sessionStorage.getItem('gm-console-mode') || 'script'; } }
  128.         function createPointer() { pointer = document.createElement('div'); pointer.id = 'gm-pointer'; Object.assign(pointer.style, { position: 'fixed', top: '0px', left: '0px', zIndex: '2147483649', transform: 'translate(-50%, -50%)', transition: 'transform 0.1s ease-out, border-color 0.2s, background-color 0.2s, border-radius 0.2s, width 0.2s, height 0.2s, box-shadow 0.2s', pointerEvents: 'none' }); document.body.appendChild(pointer); }
  129.         const updateUIVisibility = () => { if(!pointer) return; pointer.style.display = scriptActive ? 'block' : 'none'; const currentStyle = POINTER_STYLES[currentPointerStyleIndex]; let borderColor = currentStyle.baseBorderColor || COLORS.NORMAL; if (currentMode === 'scroll') { borderColor = COLORS.SCROLL; } pointer.style.borderColor = borderColor; };
  130.         function applyPointerStyle() { if (!pointer) return; const style = POINTER_STYLES[currentPointerStyleIndex]; Object.assign(pointer.style, { width: style.width, height: style.height, backgroundColor: style.backgroundColor, border: style.border, borderRadius: style.borderRadius, boxShadow: style.boxShadow, }); updateUIVisibility(); }
  131.         const dispatchMouseEvent = (type, target, options) => { if (!target) return; const eventOptions = { bubbles: true, cancelable: true, view: window, clientX: options.x, clientY: options.y, pointerType: 'mouse', isPrimary: true, button: options.button || 0, ...options }; target.dispatchEvent(new (typeof PointerEvent === 'function' ? PointerEvent : MouseEvent)(type, eventOptions)); };
  132.         const clickAtPoint = (x, y) => {
  133.             let elements = document.elementsFromPoint(x, y);
  134.             let el = elements.find(e => e.id.startsWith('gm-dialog-') || e.id.startsWith('gm-console-') || e.isContentEditable || ['INPUT', 'TEXTAREA'].includes(e.tagName));
  135.             if (!el) el = elements[0];
  136.             if (!el) return;
  137.             if (el.id.startsWith('gm-dialog-')) { if (el.tagName === 'BUTTON') el.click(); else if (el.tagName === 'INPUT' && !textInputMode) { textInputMode = true; el.focus(); } return; }
  138.             if (el.id === 'gm-console-input') { textInputMode = true; el.focus(); el.placeholder='Execute JavaScript...'; return; }
  139.             if (el.id.startsWith('gm-')) return;
  140.             if (['INPUT', 'TEXTAREA'].includes(el.tagName) || el.isContentEditable) { textInputMode = true; el.focus(); return; }
  141.             dispatchMouseEvent('mousedown', el, { x, y }); dispatchMouseEvent('mouseup', el, { x, y }); dispatchMouseEvent('click', el, { x, y });
  142.         };
  143.         const findScrollableParent = (element) => { if (!element) return null; let el = element; while (el && el !== document.body && el !== document.documentElement) { const style = window.getComputedStyle(el); if ((style.overflowY === 'scroll' || style.overflowY === 'auto' || style.overflowX === 'scroll' || style.overflowX === 'auto') && (el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth)) { return el; } el = el.parentElement; } return null; };
  144.         const exitTextInputMode = (isSilent = false) => { textInputMode = false; if (document.activeElement && (document.activeElement.id === 'gm-console-input' || document.activeElement.id.startsWith('gm-dialog-input'))) { if (document.activeElement.id === 'gm-console-input') document.activeElement.placeholder = 'Click to activate...'; } if (document.activeElement) document.activeElement.blur(); };
  145.         const updateTunerText = () => { if (tunerValueElement) tunerValueElement.textContent = `${SETTINGS.POINTER_ACCELERATION_TIME} ms`; };
  146.         const gameLoop = () => { const now = performance.now(); const deltaTime = (now - lastFrameTime) / 1000.0; lastFrameTime = now; if (scriptActive && !textInputMode && !tunerIsVisible) { if (currentMode === 'pointer') { if (keysDown.Enter && !isDragging && (now - enterHoldStartTime > SETTINGS.ENTER_HOLD_THRESHOLD)) { isDragging = true; pointer.style.display = 'none'; dragTarget = document.elementsFromPoint(cursor.x, cursor.y).find(e => !e.id.startsWith('gm-')) || window; pointer.style.display = 'block'; dispatchMouseEvent('mousedown', dragTarget, { x: cursor.x, y: cursor.y }); } let moveX = 0, moveY = 0; for (const key in keysDown) { if (key === 'Enter') continue; const rampFactor = Math.min(1, (now - (keysDown[key] || now)) / SETTINGS.POINTER_ACCELERATION_TIME); const currentSpeed = SETTINGS.POINTER_INITIAL_SPEED + (SETTINGS.POINTER_TOP_SPEED - SETTINGS.POINTER_INITIAL_SPEED) * rampFactor; if (key === 'ArrowUp') moveY -= currentSpeed; if (key === 'ArrowDown') moveY += currentSpeed; if (key === 'ArrowLeft') moveX -= currentSpeed; if (key === 'ArrowRight') moveX += currentSpeed; } cursor.x += moveX * deltaTime; cursor.y += moveY * deltaTime; if (isDragging) { dispatchMouseEvent('mousemove', dragTarget, { x: cursor.x, y: cursor.y }); } cursor.x = Math.max(0, Math.min(window.innerWidth, cursor.x)); cursor.y = Math.max(0, Math.min(window.innerHeight, cursor.y)); } else if (currentMode === 'scroll') { const target = scrollTarget || window; for (const key in keysDown) { if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) continue; const holdDuration = now - (keysDown[key] || now); const rampFactor = Math.min(1, holdDuration / SETTINGS.SCROLL_ACCELERATION_TIME); const currentSpeed = SETTINGS.SCROLL_SPEED_INITIAL + (SETTINGS.SCROLL_SPEED_MAX - SETTINGS.SCROLL_SPEED_INITIAL) * rampFactor; if (key === 'ArrowUp') target.scrollBy(0, -currentSpeed); if (key === 'ArrowDown') target.scrollBy(0, currentSpeed); if (key === 'ArrowLeft') target.scrollBy(-currentSpeed, 0); if (key === 'ArrowRight') target.scrollBy(currentSpeed, 0); } } if(pointer) pointer.style.transform = `translate(${cursor.x}px, ${cursor.y}px) translate(-50%, -50%) scale(${isDragging ? '0.8' : '1'})`; } requestAnimationFrame(gameLoop); };
  147.         const handleKeyDown = (e) => {
  148.             if (modalOverlay && modalOverlay.style.display === 'flex' && !textInputMode) {
  149.                 if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Enter'].includes(e.key)) {
  150.                      if (!keysDown[e.key]) { keysDown[e.key] = performance.now(); }
  151.                 } else { e.preventDefault(); e.stopImmediatePropagation(); }
  152.                 return;
  153.             }
  154.             if (e.key === '6') { escapeKeyPressed = true; e.preventDefault(); e.stopImmediatePropagation(); return; }
  155.             if (consoleIsVisible && document.activeElement === consoleInputElement) return;
  156.             if (e.key === '4') { e.preventDefault(); e.stopPropagation(); toggleConsole(); return; }
  157.             if (e.key === '5') { e.preventDefault(); e.stopPropagation(); toggleTuner(); return; }
  158.             if (tunerIsVisible) { if (e.key === 'ArrowLeft') { SETTINGS.POINTER_ACCELERATION_TIME = Math.max(100, SETTINGS.POINTER_ACCELERATION_TIME - 50); updateTunerText(); } else if (e.key === 'ArrowRight') { SETTINGS.POINTER_ACCELERATION_TIME = Math.min(2000, SETTINGS.POINTER_ACCELERATION_TIME + 50); updateTunerText(); } e.preventDefault(); e.stopPropagation(); return; }
  159.             if (textInputMode) { if (['3', 'Escape'].includes(e.key)) { e.preventDefault(); e.stopPropagation(); exitTextInputMode(); } return; }
  160.             if (e.key === '1') { e.preventDefault(); e.stopPropagation(); scriptActive = !scriptActive; updateUIVisibility(); return; }
  161.             if (!scriptActive) return;
  162.             if (e.key === '8') { e.preventDefault(); e.stopPropagation(); currentPointerStyleIndex = (currentPointerStyleIndex + 1) % POINTER_STYLES.length; applyPointerStyle(); return; }
  163.             if (e.key === '2') { e.preventDefault(); e.stopPropagation(); currentMode = (currentMode === 'pointer') ? 'scroll' : 'pointer'; scrollTarget = findScrollableParent(document.elementFromPoint(cursor.x, cursor.y)); updateUIVisibility(); return; }
  164.             if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Enter'].includes(e.key)) { e.preventDefault(); e.stopPropagation(); if (!keysDown[e.key]) { keysDown[e.key] = performance.now(); if (e.key === 'Enter') enterHoldStartTime = keysDown.Enter; } }
  165.         };
  166.         const handleKeyUp = (e) => {
  167.             if (modalOverlay && modalOverlay.style.display === 'flex' && !textInputMode) { if (e.key === 'Enter') { clickAtPoint(cursor.x, cursor.y); } delete keysDown[e.key]; return; }
  168.             if (e.key === '6') { escapeKeyPressed = false; }
  169.             if (!scriptActive || textInputMode || tunerIsVisible) { delete keysDown[e.key]; return; }
  170.             if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Enter'].includes(e.key)) { e.preventDefault(); e.stopPropagation(); if (e.key === 'Enter') { if (isDragging) { dispatchMouseEvent('mouseup', dragTarget, { x: cursor.x, y: cursor.y }); } else { clickAtPoint(cursor.x, cursor.y); } isDragging = false; dragTarget = null; } delete keysDown[e.key]; }
  171.         };
  172.        
  173.         currentMode = 'pointer'; isDragging = false; enterHoldStartTime = 0; dragTarget = null; textInputMode = false; scrollTarget = null; escapeKeyPressed = false; currentPointerStyleIndex = 0;
  174.         createDebugUI(); createTunerUI(); createPointer(); createModalOverlay();
  175.         loadState();
  176.         updateConsoleModeButtons(); updateTunerText(); applyPointerStyle();
  177.         if (consoleIsVisible) { debugConsole.style.display = 'flex'; renderLogs(); }
  178.         if (scriptActive) { updateUIVisibility(); }
  179.         uiReady = true;
  180.         scriptConsole.info("Universal Pointer & Console is ready.");
  181.         setInterval(() => { if (document.activeElement && document.activeElement.tagName === 'IFRAME' && escapeKeyPressed) { window.focus(); escapeKeyPressed = false; } }, 100);
  182.         document.addEventListener('keydown', handleKeyDown, true); document.addEventListener('keyup', handleKeyUp, true); window.addEventListener('beforeunload', saveState);
  183.         requestAnimationFrame(gameLoop);
  184.     }
  185.  
  186.     document.addEventListener('DOMContentLoaded', initializeScript, { once: true });
  187. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement