From 5c4065279a076ac051e9529328b36dae846598f8 Mon Sep 17 00:00:00 2001 From: Ajay Date: Tue, 10 Dec 2024 19:04:43 -0500 Subject: [PATCH] Fix title on watch page sometimes becoming hidden and not coming back --- maze-utils | 2 +- src/videoBranding/videoBranding.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/maze-utils b/maze-utils index c92044a..dce7b17 160000 --- a/maze-utils +++ b/maze-utils @@ -1 +1 @@ -Subproject commit c92044ab314ed0b52250016a3c6c3c8922787c47 +Subproject commit dce7b176bcda60fd219d7e5eee89dec9c7b5c955 diff --git a/src/videoBranding/videoBranding.ts b/src/videoBranding/videoBranding.ts index d7f657c..8aa528e 100644 --- a/src/videoBranding/videoBranding.ts +++ b/src/videoBranding/videoBranding.ts @@ -1,6 +1,6 @@ import { getYouTubeTitleNodeSelector } from "../../maze-utils/src/elements"; import { getVideoID, isOnChannelPage, VideoID } from "../../maze-utils/src/video"; -import { getElement, isVisible, waitForElement } from "../../maze-utils/src/dom"; +import { getElement, isVisibleOrParent, waitForElement } from "../../maze-utils/src/dom"; import { ThumbnailResult } from "../thumbnails/thumbnailData"; import { replaceThumbnail } from "../thumbnails/thumbnailRenderer"; import { TitleResult } from "../titles/titleData"; @@ -72,17 +72,18 @@ export async function replaceCurrentVideoBranding(): Promise<[boolean, boolean]> // Find first invisible one, or wait for the first one to be visible const mainTitle = await (async () => { if (!onChannelPage) { - const firstVisible = possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility, true) as HTMLElement).filter((element) => isVisible(element, true))[0]; + const firstVisible = possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility, true, true) as HTMLElement) + .filter((element) => isVisibleOrParent(element, true, true))[0]; if (firstVisible) return firstVisible; } return await waitForElement(possibleSelectors[0].selector, !onClipPage, true) as HTMLElement; })(); - const titles = (possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility && !onClipPage, true)).filter((e) => !!e)) as HTMLElement[]; + const titles = (possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility && !onClipPage, true, true)).filter((e) => !!e)) as HTMLElement[]; const promises: [Promise, Promise] = [Promise.resolve(false), Promise.resolve(false)] const videoID = getVideoID(); - if (videoID !== null && (isVisible(mainTitle, true) || onClipPage)) { + if (videoID !== null && (isVisibleOrParent(mainTitle, true, true) || onClipPage)) { const videoBrandingInstance = getAndUpdateVideoBrandingInstances(videoID, async () => { await replaceCurrentVideoBranding(); }); const brandingLocation = onWatchPage ? BrandingLocation.Watch : BrandingLocation.ChannelTrailer;