// ==UserScript== // @name GeoFS User Interface Hider // @namespace http://tampermonkey.net/ // @version 1.0 // @description Robust GeoFS UI hider using injected CSS and restores it. Focuses the canvas after hiding so keyboard input continues. // @author RYANAIR5719 // @match https://geo-fs.com/geofs.php* // @icon https://www.google.com/s2/favicons?sz=64&domain=geo-fs.com // @license GNU GPLv3 // @grant none // @updateURL https://raw.githubusercontent.com/RYANAIR5719/GeoFS-User-Interface-Hider/main/userscript.js // @downloadURL https://raw.githubusercontent.com/RYANAIR5719/GeoFS-User-Interface-Hider/main/userscript.js // @run-at document-end // ==/UserScript== (function () { 'use strict'; const HIDE_STYLE_ID = 'geoFS-hide-style-v1-6'; const CANVAS_EXTRA_PX = 36; const UI_SELECTORS_CSS = [ '.geofs-ui-bottom', '.geofs-auth.geofs-htmlView', '.geofs-home-button.geofs-hideForApp', '.control-pad.geofs-autopilot-pad', '.geofs-instruments-container', '.geofs-ui-right', '.geofs-sd-logo', '.geofs-sr-logo', '.geofs-hd-logo' ]; let isHidden = false; let previousCanvasTabIndex = null; function makeHideCss() { const uiList = UI_SELECTORS_CSS.join(',\n'); return ` ${uiList} { display: none !important; visibility: visible !important; } .geofs-ui-center { background: transparent !important; padding-bottom: 0 !important; height: calc(100% + ${CANVAS_EXTRA_PX}px) !important; box-sizing: border-box !important; } canvas { height: calc(100% + ${CANVAS_EXTRA_PX}px) !important; image-rendering: pixelated !important; } `; } function injectHideStyle() { if (document.getElementById(HIDE_STYLE_ID)) return; const s = document.createElement('style'); s.id = HIDE_STYLE_ID; s.type = 'text/css'; s.appendChild(document.createTextNode(makeHideCss())); (document.head || document.documentElement).appendChild(s); } function removeHideStyle() { const s = document.getElementById(HIDE_STYLE_ID); if (s) s.remove(); } function findGeoFsCanvas() { const canvases = Array.from(document.querySelectorAll('canvas')); for (const c of canvases) { try { const ir = getComputedStyle(c).imageRendering; if (ir && ir.toLowerCase().includes('pixel')) return c; } catch (e) {} } return canvases[0] || null; } function focusCanvas(canvas) { if (!canvas) { try { window.focus(); } catch (e) {} return; } try { if (previousCanvasTabIndex === null) { previousCanvasTabIndex = canvas.hasAttribute('tabindex') ? canvas.getAttribute('tabindex') : null; } canvas.setAttribute('tabindex', '-1'); canvas.focus({ preventScroll: true }); setTimeout(() => { try { canvas.focus({ preventScroll: true }); } catch (e) {} }, 50); } catch (e) { try { window.focus(); } catch (e2) {} } } function restoreCanvasFocus(canvas) { if (!canvas) return; try { if (previousCanvasTabIndex === null) { canvas.removeAttribute('tabindex'); } else { canvas.setAttribute('tabindex', previousCanvasTabIndex); } previousCanvasTabIndex = null; } catch (e) {} } function hideAll() { injectHideStyle(); const c = findGeoFsCanvas(); focusCanvas(c); isHidden = true; } function showAll() { removeHideStyle(); const c = findGeoFsCanvas(); restoreCanvasFocus(c); isHidden = false; } function toggleUI() { if (isHidden) showAll(); else hideAll(); } document.addEventListener('keyup', (event) => { try { if (!event || typeof event.key !== 'string') return; if (event.ctrlKey || event.altKey || event.metaKey) return; const targ = event.target; if (targ && (targ.tagName === 'INPUT' || targ.tagName === 'TEXTAREA' || targ.isContentEditable)) return; if (event.key.toLowerCase() === 'u') { toggleUI(); } } catch (e) { console.warn('GeoFS UI HideShow error', e); } }); setTimeout(() => {}, 1000); })();