const { ipcRenderer } = require('electron'); let trafficLightsOn = false; let lastResized = false; let lastSize = null; ipcRenderer.on('resize', () => { lastResized = true; }) ipcRenderer.on('resize-normal', () => { lastResized = false; }) ipcRenderer.on('traffic-lights-on', () => { trafficLightsOn = true; }) ipcRenderer.on('traffic-lights-off', () => { trafficLightsOn = false; }) window.addEventListener("load", () => { let css = ` .NavBar-container-F87RQ_ { -webkit-app-region: drag; } a.NavBarButton-button-cMcOo3.Link-link-SxPFpG.Link-link-SxPFpG.Link-default-BXtKLo { display: none; } .NavBar-buttonSeparator-racpPW { display: none; } a.pksp574._11ni0ce1e._11ni0cea._11ni0cen1[href="#!/announcements"] { display: none; } a.pksp574._11ni0ce1e._11ni0cea._11ni0cen1[href="https://support.plex.tv?utm_source=Plex%20Apps&utm_medium=Plex%20Web&utm_campaign=Plex%20Apps"] { display: none; } a.pksp574._11ni0ce1e._11ni0cea._11ni0cen1[href="https://plex.tv/downloads"] { display: none; } a.MenuItem-menuItem-C_KBbX.MenuItem-default-NAJl2g.Link-link-SxPFpG.Link-default-BXtKLo { display: none; } .FullPlayerTopControls-topControls-Fp11QH, .Player-fullPlayerContainer-wBDz23 .BottomBar-bottomBar-hnsKzI { backdrop-filter: blur(10px); }`; let styleSheet = document.createElement("style"); styleSheet.innerText = css; document.head.appendChild(styleSheet); let lastShown = false; let knownHeight = 0; setInterval(() => { if (document.querySelector(".Player-fullPlayerContainer-wBDz23")) { if (lastShown === false) { lastShown = true; console.log("Play!"); let height = Math.round(((document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoHeight * window.innerWidth) / document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoWidth)); console.log(document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoWidth + "x" + document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoHeight); knownHeight = height; console.log(window.innerWidth + "x" + height); if (!lastSize) lastSize = window.innerHeight; lastResized = false; if (currentHeight > 0 && !isNaN(currentHeight)) ipcRenderer.send("resize-to-match", height); } let currentHeight = Math.round(((document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoHeight * window.innerWidth) / document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoWidth)); if (knownHeight !== currentHeight) { Math.round(((document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoHeight * window.innerWidth) / document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoWidth)); console.log(document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoWidth + "x" + document.querySelector(".HTMLMedia-mediaElement-u17S9P").videoHeight); console.log(window.innerWidth + "x" + currentHeight); if (!lastSize) lastSize = window.innerHeight; lastResized = false; if (currentHeight > 0 && !isNaN(currentHeight)) ipcRenderer.send("resize-to-match", currentHeight); } knownHeight = currentHeight; } else { console.log(lastResized, lastSize); if (!lastResized && lastSize && lastSize > 0 && !isNaN(lastSize)) { ipcRenderer.send("resize-to-match", lastSize); lastResized = true; lastSize = null; } lastShown = false; } }) if (require('os').platform() === "darwin") { trafficLightsOn = true; setInterval(() => { showTrafficLights(); }); showTrafficLights(); } }) function showTrafficLights() { try { if (trafficLightsOn) { document.querySelector("._11ni0ce12._11ni0ce9._11ni0ce1m._11ni0ce2a._11ni0ce2i._11ni0ce2u._11ni0ce3a").style.marginLeft = "75px"; document.querySelector("button.PlayerIconButton-playerButton-zDmEsI.IconButton-button-s4bVCh.Link-link-SxPFpG.Link-default-BXtKLo[data-testid=\"minimizePlayerButton\"]").style.marginLeft = "80px"; } else { document.querySelector("._11ni0ce12._11ni0ce9._11ni0ce1m._11ni0ce2a._11ni0ce2i._11ni0ce2u._11ni0ce3a").style.marginLeft = "0px"; document.querySelector("button.PlayerIconButton-playerButton-zDmEsI.IconButton-button-s4bVCh.Link-link-SxPFpG.Link-default-BXtKLo[data-testid=\"minimizePlayerButton\"]").style.marginLeft = "0px"; } } catch (e) {} }