From 37207f00cd8079a0e8c348d75b9307a49cb06025 Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 11:30:20 -0700 Subject: [PATCH 1/7] fix(Youtube Music): timestamps --- websites/Y/YouTube Music/metadata.json | 6 ++++++ websites/Y/YouTube Music/presence.ts | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/websites/Y/YouTube Music/metadata.json b/websites/Y/YouTube Music/metadata.json index f3c6010c0b39..d1b017e5bc89 100644 --- a/websites/Y/YouTube Music/metadata.json +++ b/websites/Y/YouTube Music/metadata.json @@ -79,6 +79,12 @@ "if": { "privacy": false } + }, + { + "id": "usetimeleft", + "title": "Use time left", + "icon": "fad fa-stopwatch", + "value": true } ] } \ No newline at end of file diff --git a/websites/Y/YouTube Music/presence.ts b/websites/Y/YouTube Music/presence.ts index cc076c972da2..8ef7351b70d4 100644 --- a/websites/Y/YouTube Music/presence.ts +++ b/websites/Y/YouTube Music/presence.ts @@ -18,6 +18,7 @@ presence.on("UpdateData", async () => { hidePaused, showBrowsing, privacyMode, + usetimeleft, ] = await Promise.all([ presence.getSetting("buttons"), presence.getSetting("timestamps"), @@ -25,6 +26,7 @@ presence.on("UpdateData", async () => { presence.getSetting("hidePaused"), presence.getSetting("browsing"), presence.getSetting("privacy"), + presence.getSetting("usetimeleft"), ]), { mediaSession } = navigator, watchID = @@ -41,9 +43,13 @@ presence.on("UpdateData", async () => { if (videoElement) { if (!videoListenerAttached) { //* If video scrobbled, update timestamps - videoElement.addEventListener("seeked", updateSongTimestamps); + videoElement.addEventListener("seeked", () => + updateSongTimestamps(usetimeleft) + ); //* If video resumes playing, update timestamps - videoElement.addEventListener("play", updateSongTimestamps); + videoElement.addEventListener("play", () => + updateSongTimestamps(usetimeleft) + ); videoListenerAttached = true; } @@ -60,7 +66,7 @@ presence.on("UpdateData", async () => { if (["playing", "paused"].includes(mediaSession.playbackState)) { if (privacyMode) { - presenceData.type = ActivityType.Listening; + presenceData.type = ActivityType.Playing; return presence.setActivity({ ...(mediaSession.playbackState === "playing" && { largeImageKey: @@ -80,7 +86,7 @@ presence.on("UpdateData", async () => { .querySelector("#left-controls > span") .textContent.trim() ) { - updateSongTimestamps(); + updateSongTimestamps(usetimeleft); if (mediaTimestamps[0] === mediaTimestamps[1]) return; @@ -145,7 +151,7 @@ presence.on("UpdateData", async () => { }; } else if (showBrowsing) { if (privacyMode) { - presenceData.type = ActivityType.Listening; + presenceData.type = ActivityType.Playing; return presence.setActivity({ largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png", @@ -260,12 +266,11 @@ presence.on("UpdateData", async () => { if (!showBrowsing) return presence.clearActivity(); - //* For some bizarre reason the timestamps are NaN eventho they are never actually set in testing, this spread is a workaround - presenceData.type = ActivityType.Listening; + presenceData.type = ActivityType.Playing; presence.setActivity(presenceData); }); -function updateSongTimestamps() { +function updateSongTimestamps(usetimeleft: boolean) { const element = document .querySelector("#left-controls > span") .textContent.trim() @@ -273,7 +278,7 @@ function updateSongTimestamps() { [currTimes, totalTimes] = element; mediaTimestamps = presence.getTimestamps( - presence.timestampFromFormat(currTimes), - presence.timestampFromFormat(totalTimes) + usetimeleft ? presence.timestampFromFormat(currTimes) : Date.now(), + usetimeleft ? presence.timestampFromFormat(totalTimes) : null ); } From aba33f1b3b15db727f6ba62c67c547289ae07574 Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 11:48:58 -0700 Subject: [PATCH 2/7] fix(Youtube Music): timestamps --- websites/Y/YouTube Music/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/Y/YouTube Music/metadata.json b/websites/Y/YouTube Music/metadata.json index d1b017e5bc89..530e270660de 100644 --- a/websites/Y/YouTube Music/metadata.json +++ b/websites/Y/YouTube Music/metadata.json @@ -82,7 +82,7 @@ }, { "id": "usetimeleft", - "title": "Use time left", + "title": "Use Time Left", "icon": "fad fa-stopwatch", "value": true } From 53069a3ac970ff3949b88dbee42547af7bd51a37 Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 11:50:24 -0700 Subject: [PATCH 3/7] fix(Youtube Music): timestamps --- websites/Y/YouTube Music/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/Y/YouTube Music/metadata.json b/websites/Y/YouTube Music/metadata.json index 530e270660de..e194223e2643 100644 --- a/websites/Y/YouTube Music/metadata.json +++ b/websites/Y/YouTube Music/metadata.json @@ -22,7 +22,7 @@ "matches": [ "*://music.youtube.com/*" ], - "version": "3.0.18", + "version": "3.0.19", "logo": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/thumbnail.png", "color": "#E40813", From 79128abafb5e8b39c4ceb4e4c6dcd303351e9ada Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 12:33:39 -0700 Subject: [PATCH 4/7] Update websites/Y/YouTube Music/presence.ts Co-authored-by: veryCrunchy Signed-off-by: ION606 --- websites/Y/YouTube Music/presence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/Y/YouTube Music/presence.ts b/websites/Y/YouTube Music/presence.ts index 8ef7351b70d4..144bdb1d0573 100644 --- a/websites/Y/YouTube Music/presence.ts +++ b/websites/Y/YouTube Music/presence.ts @@ -66,7 +66,7 @@ presence.on("UpdateData", async () => { if (["playing", "paused"].includes(mediaSession.playbackState)) { if (privacyMode) { - presenceData.type = ActivityType.Playing; + presenceData.type = ActivityType.Listening; return presence.setActivity({ ...(mediaSession.playbackState === "playing" && { largeImageKey: From 452ebec0b571b47e9853d3e313849fd0cc6c5dad Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 12:33:44 -0700 Subject: [PATCH 5/7] Update websites/Y/YouTube Music/presence.ts Co-authored-by: veryCrunchy Signed-off-by: ION606 --- websites/Y/YouTube Music/presence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/Y/YouTube Music/presence.ts b/websites/Y/YouTube Music/presence.ts index 144bdb1d0573..b48728d462fc 100644 --- a/websites/Y/YouTube Music/presence.ts +++ b/websites/Y/YouTube Music/presence.ts @@ -266,7 +266,7 @@ presence.on("UpdateData", async () => { if (!showBrowsing) return presence.clearActivity(); - presenceData.type = ActivityType.Playing; + presenceData.type = ActivityType.Listening; presence.setActivity(presenceData); }); From ddb50656dbccf2f4d9068a430495936c9eb5d6da Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 12:33:51 -0700 Subject: [PATCH 6/7] Update websites/Y/YouTube Music/presence.ts Co-authored-by: veryCrunchy Signed-off-by: ION606 --- websites/Y/YouTube Music/presence.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/websites/Y/YouTube Music/presence.ts b/websites/Y/YouTube Music/presence.ts index b48728d462fc..ab4318225db2 100644 --- a/websites/Y/YouTube Music/presence.ts +++ b/websites/Y/YouTube Music/presence.ts @@ -151,7 +151,7 @@ presence.on("UpdateData", async () => { }; } else if (showBrowsing) { if (privacyMode) { - presenceData.type = ActivityType.Playing; + presenceData.type = ActivityType.Listening; return presence.setActivity({ largeImageKey: "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube%20Music/assets/logo.png", From 08f14cb52e401b496caffc2f49c48028aef7195e Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 12:39:24 -0700 Subject: [PATCH 7/7] fix(YouTube Music): timestamps --- websites/Y/YouTube Music/metadata.json | 2 +- websites/Y/YouTube Music/presence.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/websites/Y/YouTube Music/metadata.json b/websites/Y/YouTube Music/metadata.json index e194223e2643..b599b12e280f 100644 --- a/websites/Y/YouTube Music/metadata.json +++ b/websites/Y/YouTube Music/metadata.json @@ -81,7 +81,7 @@ } }, { - "id": "usetimeleft", + "id": "useTimeLeft", "title": "Use Time Left", "icon": "fad fa-stopwatch", "value": true diff --git a/websites/Y/YouTube Music/presence.ts b/websites/Y/YouTube Music/presence.ts index 8ef7351b70d4..2c56fc62c49d 100644 --- a/websites/Y/YouTube Music/presence.ts +++ b/websites/Y/YouTube Music/presence.ts @@ -18,7 +18,7 @@ presence.on("UpdateData", async () => { hidePaused, showBrowsing, privacyMode, - usetimeleft, + useTimeLeft, ] = await Promise.all([ presence.getSetting("buttons"), presence.getSetting("timestamps"), @@ -26,7 +26,7 @@ presence.on("UpdateData", async () => { presence.getSetting("hidePaused"), presence.getSetting("browsing"), presence.getSetting("privacy"), - presence.getSetting("usetimeleft"), + presence.getSetting("useTimeLeft"), ]), { mediaSession } = navigator, watchID = @@ -44,11 +44,11 @@ presence.on("UpdateData", async () => { if (!videoListenerAttached) { //* If video scrobbled, update timestamps videoElement.addEventListener("seeked", () => - updateSongTimestamps(usetimeleft) + updateSongTimestamps(useTimeLeft) ); //* If video resumes playing, update timestamps videoElement.addEventListener("play", () => - updateSongTimestamps(usetimeleft) + updateSongTimestamps(useTimeLeft) ); videoListenerAttached = true; @@ -86,7 +86,7 @@ presence.on("UpdateData", async () => { .querySelector("#left-controls > span") .textContent.trim() ) { - updateSongTimestamps(usetimeleft); + updateSongTimestamps(useTimeLeft); if (mediaTimestamps[0] === mediaTimestamps[1]) return; @@ -270,7 +270,7 @@ presence.on("UpdateData", async () => { presence.setActivity(presenceData); }); -function updateSongTimestamps(usetimeleft: boolean) { +function updateSongTimestamps(useTimeLeft: boolean) { const element = document .querySelector("#left-controls > span") .textContent.trim() @@ -278,7 +278,7 @@ function updateSongTimestamps(usetimeleft: boolean) { [currTimes, totalTimes] = element; mediaTimestamps = presence.getTimestamps( - usetimeleft ? presence.timestampFromFormat(currTimes) : Date.now(), - usetimeleft ? presence.timestampFromFormat(totalTimes) : null + useTimeLeft ? presence.timestampFromFormat(currTimes) : Date.now(), + useTimeLeft ? presence.timestampFromFormat(totalTimes) : null ); }