Skip to content

Commit

Permalink
Fix title on watch page sometimes becoming hidden and not coming back
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Dec 11, 2024
1 parent 44bb587 commit 5c40652
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion maze-utils
Submodule maze-utils updated 1 files
+12 −8 src/dom.ts
9 changes: 5 additions & 4 deletions src/videoBranding/videoBranding.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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<boolean>, Promise<boolean>] = [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;
Expand Down

0 comments on commit 5c40652

Please # to comment.