Skip to content

Commit

Permalink
Extension - new (spring 2024) UI support
Browse files Browse the repository at this point in the history
Add new player selector for isVideoLoaded() (fixes Anarios#1043)
  • Loading branch information
theblackhole committed Apr 17, 2024
1 parent 27d97a8 commit de6c110
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Extensions/combined/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -98,6 +93,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
Expand Down

0 comments on commit de6c110

Please sign in to comment.