diff options
author | Ajay <[email protected]> | 2024-11-27 23:54:09 -0500 |
---|---|---|
committer | Ajay <[email protected]> | 2024-11-27 23:54:09 -0500 |
commit | cfa8eee19352e9dbdf23872def6d815ca7fc40c8 (patch) | |
tree | ecf9b4d59213068d6851493bc5b7673577fd026d | |
parent | 14f8ee565a7221f882412356110c9801193b3d65 (diff) | |
download | SponsorBlock-cfa8eee19352e9dbdf23872def6d815ca7fc40c8.tar.gz SponsorBlock-cfa8eee19352e9dbdf23872def6d815ca7fc40c8.zip |
Fix full video label sometimes not appearing when you open a video in a background tab
m--------- | maze-utils | 0 | ||||
-rw-r--r-- | src/content.ts | 8 | ||||
-rw-r--r-- | src/render/CategoryPill.tsx | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/maze-utils b/maze-utils -Subproject 6770087140715ab4f7d298add61770da63157b7 +Subproject 7a49dc6d5e77e53c6f4c57299012134bd0d7f50 diff --git a/src/content.ts b/src/content.ts index 222f9514..2cb5f6a2 100644 --- a/src/content.ts +++ b/src/content.ts @@ -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"; @@ -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(); @@ -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) { diff --git a/src/render/CategoryPill.tsx b/src/render/CategoryPill.tsx index 20923fba..3a11e09c 100644 --- a/src/render/CategoryPill.tsx +++ b/src/render/CategoryPill.tsx @@ -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 @@ -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, |