feat: HUD BrowserWindow — loads fox.pxo.at/hud with preload injection

main
boksbc 2026-05-11 21:57:39 +02:00
parent 6c5efac934
commit 364344c3ca
1 changed files with 53 additions and 0 deletions

53
electron/hud.js Normal file
View File

@ -0,0 +1,53 @@
const { BrowserWindow, screen } = require('electron');
const path = require('path');
const HUD_URL = process.env.FOX_HUD_URL || 'https://fox.pxo.at/hud';
let hudWindow = null;
function createHud() {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
hudWindow = new BrowserWindow({
width,
height,
x: 0,
y: 0,
frame: false,
transparent: true,
alwaysOnTop: true,
show: false,
skipTaskbar: true,
hasShadow: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
nodeIntegration: false,
webSecurity: false,
allowRunningInsecureContent: true,
},
});
hudWindow.setAlwaysOnTop(true, 'screen-saver');
hudWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
hudWindow.loadURL(HUD_URL);
hudWindow.on('closed', () => { hudWindow = null; });
return hudWindow;
}
function showHud() {
if (!hudWindow) createHud();
hudWindow.show();
hudWindow.focus();
hudWindow.webContents.send('hud-show');
}
function hideHud() {
if (!hudWindow) return;
hudWindow.webContents.send('hud-hide');
setTimeout(() => {
if (hudWindow) hudWindow.hide();
}, 600);
}
module.exports = { createHud, showHud, hideHud };