From cb64ebf4ea087024f9022be66dd12677837d1042 Mon Sep 17 00:00:00 2001 From: hanyd Date: Sat, 14 Sep 2024 16:23:42 +0800 Subject: [PATCH] Add video ID hash type --- src/content.ts | 11 ++++++----- src/types.ts | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/content.ts b/src/content.ts index 480f5347..b530ee39 100644 --- a/src/content.ts +++ b/src/content.ts @@ -29,6 +29,7 @@ import { SponsorHideType, SponsorSourceType, SponsorTime, + SponsorTimeHashedID, ToggleSkippable, VideoID, VideoInfo, @@ -1143,17 +1144,17 @@ async function sponsorsLookup(keepOldSubmissions = true, ignoreServerCache = fal if (response?.ok) { const receivedSegments: SponsorTime[] = JSON.parse(response.responseText) - ?.filter((video) => video.videoID === getVideoID()) - ?.map((video) => video.segments)?.[0] + ?.filter((video: SponsorTimeHashedID) => video.videoID === getVideoID()) + ?.map((video: SponsorTimeHashedID) => video.segments)?.[0] ?.filter( - (segment) => + (segment: SponsorTime) => getEnabledActionTypes().includes(segment.actionType) && categories.includes(segment.category) ) - ?.map((segment) => ({ + ?.map((segment: SponsorTime) => ({ ...segment, source: SponsorSourceType.Server, })) - ?.sort((a, b) => a.segment[0] - b.segment[0]); + ?.sort((a: SponsorTime, b: SponsorTime) => a.segment[0] - b.segment[0]); if (receivedSegments && receivedSegments.length) { sponsorDataFound = true; diff --git a/src/types.ts b/src/types.ts index 749c3a88..9ddbc2a8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -92,6 +92,11 @@ export interface SponsorTime { videoDuration?: number; } +export interface SponsorTimeHashedID { + videoID: VideoID; + segments: SponsorTime[]; +} + export interface ScheduledTime extends SponsorTime { scheduledTime: number; }