diff --git a/src/content.ts b/src/content.ts index bac12af0..49883859 100644 --- a/src/content.ts +++ b/src/content.ts @@ -6,7 +6,7 @@ import { SkipButtonControlBar } from "./js-components/skipButtonControlBar"; import { Message, MessageResponse, VoteResponse } from "./messageTypes"; import { CategoryPill } from "./render/CategoryPill"; import { ChapterVote } from "./render/ChapterVote"; -import { DescriptionPortPill } from "./render/DesciptionPortPill"; +import { DescriptionPortPill, PortVideo } from "./render/DesciptionPortPill"; import { setMessageNotice, showMessage } from "./render/MessageNotice"; import { PlayerButton } from "./render/PlayerButton"; import SkipNotice from "./render/SkipNotice"; @@ -93,6 +93,8 @@ let shownSegmentFailedToFetchWarning = false; let selectedSegment: SegmentUUID | null = null; let previewedSegment = false; +let portVideo: PortVideo = null; + // JSON video info let videoInfo: VideoInfo = null; // Locked Categories in this tab, like: ["sponsor","intro","outro"] @@ -246,10 +248,12 @@ function messageListener( break; case "isInfoFound": //send the sponsor times along with if it's found + console.log(portVideo); sendResponse({ found: sponsorDataFound, status: lastResponseStatus, sponsorTimes: sponsorTimes, + portVideo: portVideo, time: getVideo()?.currentTime ?? 0, }); @@ -1232,11 +1236,15 @@ function setupCategoryPill() { function setupDescriptionPill() { if (!descriptionPill) { - descriptionPill = new DescriptionPortPill(sponsorsLookup); + descriptionPill = new DescriptionPortPill(updatePortvideo, sponsorsLookup); } descriptionPill.setupDecription(getVideoID()); } +function updatePortvideo(newPortVideo: PortVideo) { + portVideo = newPortVideo; +} + async function sponsorsLookup(keepOldSubmissions = true, ignoreServerCache = false, forceUpdatePreviewBar = false) { if (lookupWaiting) return; //there is still no video here diff --git a/src/messageTypes.ts b/src/messageTypes.ts index 8bbbfca5..e68eeca6 100644 --- a/src/messageTypes.ts +++ b/src/messageTypes.ts @@ -2,6 +2,7 @@ // Message and Response Types // +import { PortVideo } from "./render/DesciptionPortPill"; import { SegmentUUID, SponsorHideType, SponsorTime } from "./types"; interface BaseMessage { @@ -86,6 +87,7 @@ export interface IsInfoFoundMessageResponse { found: boolean; status: number; sponsorTimes: SponsorTime[]; + portVideo: PortVideo; time: number; } diff --git a/src/render/DesciptionPortPill.tsx b/src/render/DesciptionPortPill.tsx index 7a7e5cf0..04752cd3 100644 --- a/src/render/DesciptionPortPill.tsx +++ b/src/render/DesciptionPortPill.tsx @@ -28,6 +28,7 @@ export class DescriptionPortPill { ytbID: VideoID; portUUID: string; hasDescription: boolean; + updatePortvideo: (newPortVideo: PortVideo) => void; sponsorsLookup: (keepOldSubmissions: boolean, ignoreServerCache: boolean, forceUpdatePreviewBar: boolean) => void; inputContainer: HTMLElement; @@ -35,7 +36,8 @@ export class DescriptionPortPill { ref: React.RefObject; root: Root; - constructor(sponsorsLookup: () => void) { + constructor(updatePortvideo: (newPortVideo: PortVideo) => void, sponsorsLookup: () => void) { + this.updatePortvideo = updatePortvideo; this.sponsorsLookup = sponsorsLookup; } @@ -163,9 +165,11 @@ export class DescriptionPortPill { if (portVideo) { this.ytbID = portVideo.ytbID; this.portUUID = portVideo.UUID; + this.updatePortvideo(portVideo); } else { this.ytbID = null; this.portUUID = null; + this.updatePortvideo(null); } }