Skip to content

Commit

Permalink
Fix full video label sometimes not appearing when you open a video in…
Browse files Browse the repository at this point in the history
… a background tab
  • Loading branch information
ajayyy committed Nov 28, 2024
1 parent 14f8ee5 commit cfa8eee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion maze-utils
Submodule maze-utils updated 1 files
+12 −0 src/video.ts
8 changes: 5 additions & 3 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { ChapterVote } from "./render/ChapterVote";
import { openWarningDialog } from "./utils/warnings";
import { isFirefoxOrSafari, waitFor } from "../maze-utils/src";
import { getErrorMessage, getFormattedTime } from "../maze-utils/src/formating";
import { getChannelIDInfo, getVideo, getIsAdPlaying, getIsLivePremiere, setIsAdPlaying, checkVideoIDChange, getVideoID, getYouTubeVideoID, setupVideoModule, checkIfNewVideoID, isOnInvidious, isOnMobileYouTube, getLastNonInlineVideoID, triggerVideoIDChange, triggerVideoElementChange, getIsInline, getCurrentTime, setCurrentTime, getVideoDuration, verifyCurrentTime } from "../maze-utils/src/video";
import { getChannelIDInfo, getVideo, getIsAdPlaying, getIsLivePremiere, setIsAdPlaying, checkVideoIDChange, getVideoID, getYouTubeVideoID, setupVideoModule, checkIfNewVideoID, isOnInvidious, isOnMobileYouTube, getLastNonInlineVideoID, triggerVideoIDChange, triggerVideoElementChange, getIsInline, getCurrentTime, setCurrentTime, getVideoDuration, verifyCurrentTime, waitForVideo } from "../maze-utils/src/video";
import { Keybind, StorageChangesObject, isSafari, keybindEquals, keybindToString } from "../maze-utils/src/config";
import { findValidElement } from "../maze-utils/src/dom"
import { getHash, HashedValue } from "../maze-utils/src/hash";
Expand Down Expand Up @@ -1230,7 +1230,7 @@ async function sponsorsLookup(keepOldSubmissions = true, ignoreCache = false) {

if (!getVideo()) {
//there is still no video here
await waitFor(() => getVideo(), 5000, 10);
await waitForVideo();
}

startSkipScheduleCheckingForStartSponsors();
Expand Down Expand Up @@ -1375,7 +1375,9 @@ function startSkipScheduleCheckingForStartSponsors() {

const fullVideoSegment = sponsorTimes.filter((time) => time.actionType === ActionType.Full)[0];
if (fullVideoSegment) {
categoryPill?.setSegment(fullVideoSegment);
waitFor(() => categoryPill).then(() => {
categoryPill?.setSegment(fullVideoSegment);
});
}

if (startingSegmentTime !== -1) {
Expand Down
4 changes: 3 additions & 1 deletion src/render/CategoryPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class CategoryPill {
}

private async attachToPageInternal(): Promise<void> {
let referenceNode =
let referenceNode =
await waitFor(() => getYouTubeTitleNode());

// Experimental YouTube layout with description on right
Expand Down Expand Up @@ -119,6 +119,8 @@ export class CategoryPill {
}

async setSegment(segment: SponsorTime): Promise<void> {
await waitFor(() => this.ref.current);

if (this.ref.current?.state?.segment !== segment) {
const newState = {
segment,
Expand Down

0 comments on commit cfa8eee

Please sign in to comment.