Skip to content

Commit

Permalink
Fix clip page breaking extension
Browse files Browse the repository at this point in the history
Closes #204
  • Loading branch information
ajayyy committed Dec 20, 2023
1 parent cd9f70b commit 5e0367a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion maze-utils
Submodule maze-utils updated 2 files
+1 −1 src/formating.ts
+11 −4 src/video.ts
3 changes: 2 additions & 1 deletion src/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export function setupCBVideoModule(): void {
resetValues,
windowListenerHandler,
newVideosLoaded,
documentScript: chrome.runtime.getManifest().manifest_version === 2 ? documentScript : undefined
documentScript: chrome.runtime.getManifest().manifest_version === 2 ? documentScript : undefined,
allowClipPage: true
}, () => Config);

if (onMobile()) {
Expand Down
9 changes: 5 additions & 4 deletions src/videoBranding/videoBranding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ const threeRingLogo = chrome.runtime.getURL("icons/logo.svg");
const videoBrandingInstances: Record<VideoID, VideoBrandingInstance> = {}

export async function replaceCurrentVideoBranding(): Promise<[boolean, boolean]> {
const onWatchPage = document.URL.includes("/watch");
const onClipPage = document.URL.includes("/clip/");
const onWatchPage = document.URL.includes("/watch") || onClipPage;
const onEmbedPage = document.URL.includes("/embed/");
const possibleSelectors = getPossibleSelectors(onWatchPage, onEmbedPage);

// Find first invisible one, or wait for the first one to be visible
const mainTitle = possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility) as HTMLElement).filter((element) => isVisible(element))[0] ||
await waitForElement(possibleSelectors[0].selector, true) as HTMLElement;
const titles = (possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility)).filter((e) => !!e)) as HTMLElement[];
await waitForElement(possibleSelectors[0].selector, !onClipPage) as HTMLElement;
const titles = (possibleSelectors.map((selector) => getElement(selector.selector, selector.checkVisibility && !onClipPage)).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)) {
if (videoID !== null && (isVisible(mainTitle) || onClipPage)) {
const videoBrandingInstance = getAndUpdateVideoBrandingInstances(videoID,
async () => { await replaceCurrentVideoBranding(); });
const brandingLocation = BrandingLocation.Watch;
Expand Down

0 comments on commit 5e0367a

Please sign in to comment.