Block alert if leaving page when playing (onbeforeunload event)

This commit is contained in:
TC
2020-10-19 22:44:39 +02:00
parent 3e97e9307c
commit 023f5b6bc3

View File

@ -92,6 +92,10 @@ function createMainWindow() {
win.webContents.loadFile(path.join(__dirname, "error.html"));
});
win.webContents.on("will-prevent-unload", (event) => {
event.preventDefault();
});
win.webContents.on("did-navigate-in-page", () => {
const url = win.webContents.getURL();
if (url.startsWith("https://music.youtube.com")) {