Skip to content

Commit

Permalink
Add video ID hash type
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Sep 14, 2024
1 parent 64da228 commit cb64ebf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
SponsorHideType,
SponsorSourceType,
SponsorTime,
SponsorTimeHashedID,
ToggleSkippable,
VideoID,
VideoInfo,
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export interface SponsorTime {
videoDuration?: number;
}

export interface SponsorTimeHashedID {
videoID: VideoID;
segments: SponsorTime[];
}

export interface ScheduledTime extends SponsorTime {
scheduledTime: number;
}
Expand Down

0 comments on commit cb64ebf

Please sign in to comment.