From 43a9093eb7bd27fb810e78c89158fc622651a1c5 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Sun, 24 Oct 2021 21:17:45 +0300 Subject: [PATCH] set resume on start url to songInfo.url --- index.js | 7 ------- providers/song-info.js | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 90096ecf..88b228f8 100644 --- a/index.js +++ b/index.js @@ -197,13 +197,6 @@ app.once("browser-window-created", (event, win) => { event.preventDefault(); }); - win.webContents.on("did-navigate-in-page", () => { - const url = win.webContents.getURL(); - if (url.startsWith("https://music.youtube.com")) { - config.set("url", url); - } - }); - win.webContents.on("will-navigate", (_, url) => { if (url.startsWith("https://accounts.google.com")) { // Force user-agent "Firefox Windows" for Google OAuth to work diff --git a/providers/song-info.js b/providers/song-info.js index 3f4ad435..37cd55fa 100644 --- a/providers/song-info.js +++ b/providers/song-info.js @@ -2,6 +2,8 @@ const { ipcMain, nativeImage } = require("electron"); const fetch = require("node-fetch"); +const config = require("../config"); + // Grab the progress using the selector const getProgress = async (win) => { // Get current value of the progressbar element @@ -56,6 +58,9 @@ const handleData = async (responseText, win) => { songInfo.uploadDate = data?.microformat?.microformatDataRenderer?.uploadDate; songInfo.url = data?.microformat?.microformatDataRenderer?.urlCanonical?.split("&")[0]; + // used for options.resumeOnStart + config.set("url", data?.microformat?.microformatDataRenderer?.urlCanonical); + win.webContents.send("update-song-info", JSON.stringify(songInfo)); };