From cfced64a2e0cb2ad7267d6f20d94010998dbbbab Mon Sep 17 00:00:00 2001 From: ION606 Date: Sun, 28 Apr 2024 18:43:27 -0700 Subject: [PATCH] fix(YouTube): add auto-hide option (#8328) --- websites/Y/YouTube/metadata.json | 11 ++++++++++- websites/Y/YouTube/presence.ts | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/websites/Y/YouTube/metadata.json b/websites/Y/YouTube/metadata.json index db92c85d14b9..17cae2c235fd 100644 --- a/websites/Y/YouTube/metadata.json +++ b/websites/Y/YouTube/metadata.json @@ -75,7 +75,7 @@ "*://www.youtube.com/*", "*://studio.youtube.com/*" ], - "version": "5.10.4", + "version": "5.10.5", "logo": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/Y/YouTube/assets/thumbnail.jpg", "color": "#E40813", @@ -95,6 +95,15 @@ "icon": "fad fa-user-secret", "value": false }, + { + "id": "hidePaused", + "title": "Hide Paused", + "icon": "fad fa-pause-circle", + "value": false, + "if": { + "privacy": false + } + }, { "id": "privacy-shown", "title": "Show Privacy Button", diff --git a/websites/Y/YouTube/presence.ts b/websites/Y/YouTube/presence.ts index 93a1ec4f0e16..4631fe0c4c81 100644 --- a/websites/Y/YouTube/presence.ts +++ b/websites/Y/YouTube/presence.ts @@ -51,6 +51,7 @@ presence.on("UpdateData", async () => { channelPic, logo, buttons, + hidePaused, ] = [ getSetting("lang", "en"), getSetting("privacy", true), @@ -62,6 +63,7 @@ presence.on("UpdateData", async () => { getSetting("channelPic", false), getSetting("logo", 0), getSetting("buttons", true), + getSetting("hidePaused", true), ], { pathname, hostname, search, href } = document.location; @@ -74,6 +76,10 @@ presence.on("UpdateData", async () => { ).find(video => video.duration); if (video) { + const { mediaSession } = navigator; + if (mediaSession.playbackState !== "playing" && hidePaused) + return presence.clearActivity(); + const resolver = [ youtubeEmbedResolver, youtubeShortsResolver,