const { app, BrowserWindow, ipcMain } = require('electron'); const path = require('path'); function createWindow () { const win = new BrowserWindow({ width: 1220, minWidth: 150, icon: require('os').platform() === "darwin" ? "icon.icns" : "icon.png", minHeight: 100, trafficLightPosition: { x: 26, y: 24 }, title: "Plex", autoHideMenuBar: true, backgroundColor: "#3c434b", darkTheme: true, titleBarStyle: "hiddenInset", tabbingIdentifier: "main", titleBarOverlay: true, height: 720, webPreferences: { nodeIntegration: false, nodeIntegrationInWorker: false, nodeIntegrationInSubFrames: false, imageAnimationPolicy: "noAnimation", webgl: false, plugins: false, experimentalFeatures: false, scrollBounce: true, sandbox: false, contextIsolation: false, safeDialogs: true, autoplayPolicy: "no-user-gesture-required", spellcheck: true, enableWebSQL: false, preload: path.join(__dirname, 'preload.js') } }) win.loadURL('https://plex.equestria.dev'); win.on("enter-full-screen", () => { win.send("traffic-lights-off"); }); win.on("leave-full-screen", () => { win.send("traffic-lights-on"); }); win.on("enter-html-full-screen", () => { win.send("traffic-lights-off"); }); win.on("leave-html-full-screen", () => { win.send("traffic-lights-on"); }); ipcMain.on("resize-to-match", (_, args) => { if (args > 0) { win.setSize(win.getSize()[0], args, true); win.send("resize-normal"); } }) win.on('resize', ()=> { win.send("resize"); }); } app.whenReady().then(() => { createWindow(); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } }); }); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } });