mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 11:51:47 +00:00
Block alert if leaving page when playing (onbeforeunload event)
This commit is contained in:
4
index.js
4
index.js
@ -92,6 +92,10 @@ function createMainWindow() {
|
|||||||
win.webContents.loadFile(path.join(__dirname, "error.html"));
|
win.webContents.loadFile(path.join(__dirname, "error.html"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
win.webContents.on("will-prevent-unload", (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
win.webContents.on("did-navigate-in-page", () => {
|
win.webContents.on("did-navigate-in-page", () => {
|
||||||
const url = win.webContents.getURL();
|
const url = win.webContents.getURL();
|
||||||
if (url.startsWith("https://music.youtube.com")) {
|
if (url.startsWith("https://music.youtube.com")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user