From 023f5b6bc3b3693fedd671dc0631bc2c57ac8ec4 Mon Sep 17 00:00:00 2001 From: TC Date: Mon, 19 Oct 2020 22:44:39 +0200 Subject: [PATCH] Block alert if leaving page when playing (onbeforeunload event) --- index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.js b/index.js index 27a577dd..75778d19 100644 --- a/index.js +++ b/index.js @@ -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")) {