From fd45f86f9a4e3f35941506ba014d3263440ef895 Mon Sep 17 00:00:00 2001 From: Enguerran P Date: Wed, 17 Apr 2024 18:55:48 +0000 Subject: [PATCH 1/2] Extension - new (spring 2024) UI support Add new player selector for isVideoLoaded() (fixes #1043) --- Extensions/combined/src/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Extensions/combined/src/utils.js b/Extensions/combined/src/utils.js index 8eef6f79..ab90c3b0 100644 --- a/Extensions/combined/src/utils.js +++ b/Extensions/combined/src/utils.js @@ -98,6 +98,9 @@ function isInViewport(element) { function isVideoLoaded() { const videoId = getVideoId(window.location.href); return ( + // desktop: spring 2024 UI + document.querySelector(`ytd-watch-grid[video-id='${videoId}']`) !== null || + // desktop: older UI document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null || // mobile: no video-id attribute document.querySelector('#player[loading="false"]:not([hidden])') !== null From fa23a377986dea7a344311c5331a21ba72519362 Mon Sep 17 00:00:00 2001 From: Enguerran P Date: Wed, 17 Apr 2024 19:21:19 +0000 Subject: [PATCH 2/2] Githook tasks for fd45f86f (in a separate commit for readability) --- Extensions/combined/src/utils.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Extensions/combined/src/utils.js b/Extensions/combined/src/utils.js index ab90c3b0..872d55fe 100644 --- a/Extensions/combined/src/utils.js +++ b/Extensions/combined/src/utils.js @@ -18,9 +18,7 @@ function getNumberFormatter(optionSelect) { ?.getAttribute("href"), )?.searchParams?.get("locale"); } catch { - cLog( - "Cannot find browser locale. Use en as default for number formatting.", - ); + cLog("Cannot find browser locale. Use en as default for number formatting."); userLocales = "en"; } } @@ -56,10 +54,7 @@ function localize(localeString) { function getBrowser() { if (typeof chrome !== "undefined" && typeof chrome.runtime !== "undefined") { return chrome; - } else if ( - typeof browser !== "undefined" && - typeof browser.runtime !== "undefined" - ) { + } else if (typeof browser !== "undefined" && typeof browser.runtime !== "undefined") { return browser; } else { console.log("browser is not supported");