SponsorBlock/src/types.ts

223 lines
5.6 KiB
TypeScript
Raw Normal View History

2020-03-12 00:35:20 +01:00
import SubmissionNotice from "./render/SubmissionNotice";
import SkipNoticeComponent from "./components/SkipNoticeComponent";
import SkipNotice from "./render/SkipNotice";
2020-03-12 00:35:20 +01:00
2021-01-17 18:56:37 +01:00
export interface ContentContainer {
2020-03-12 00:35:20 +01:00
(): {
2022-10-08 02:51:58 +02:00
vote: (type: number, UUID: SegmentUUID, category?: Category, skipNotice?: SkipNoticeComponent) => void;
dontShowNoticeAgain: () => void;
unskipSponsorTime: (segment: SponsorTime, unskipTime: number, forceSeek?: boolean) => void;
sponsorTimes: SponsorTime[];
sponsorTimesSubmitting: SponsorTime[];
skipNotices: SkipNotice[];
v: HTMLVideoElement;
sponsorVideoID;
reskipSponsorTime: (segment: SponsorTime, forceSeek?: boolean) => void;
updatePreviewBar: () => void;
onMobileYouTube: boolean;
sponsorSubmissionNotice: SubmissionNotice;
resetSponsorSubmissionNotice: (callRef?: boolean) => void;
updateEditButtonsOnPlayer: () => void;
previewTime: (time: number, unpause?: boolean) => void;
videoInfo: VideoInfo;
getRealCurrentTime: () => number;
lockedCategories: string[];
channelIDInfo: ChannelIDInfo;
};
2020-03-12 00:35:20 +01:00
}
2021-01-17 18:56:37 +01:00
export interface VideoDurationResponse {
2020-01-29 05:52:15 +01:00
duration: number;
}
2021-01-17 18:56:37 +01:00
export enum CategorySkipOption {
Disabled = -1,
ShowOverlay,
ManualSkip,
AutoSkip
}
2021-01-17 18:56:37 +01:00
export interface CategorySelection {
2021-04-06 05:35:05 +02:00
name: Category;
2022-10-08 02:51:58 +02:00
option: CategorySkipOption;
2020-04-03 04:13:36 +02:00
}
2020-03-12 00:35:20 +01:00
2021-01-17 18:56:37 +01:00
export enum SponsorHideType {
Visible = undefined,
Downvoted = 1,
2022-02-07 03:03:39 +01:00
MinimumDuration,
Hidden,
}
export enum ActionType {
Skip = "skip",
2021-10-13 05:33:41 +02:00
Mute = "mute",
Chapter = "chapter",
Full = "full",
Poi = "poi"
}
export const ActionTypes = [ActionType.Skip, ActionType.Mute];
2021-04-06 05:35:05 +02:00
export type SegmentUUID = string & { __segmentUUIDBrand: unknown };
export type Category = string & { __categoryBrand: unknown };
export enum SponsorSourceType {
Server = undefined,
2022-02-23 03:22:30 +01:00
Local = 1,
YouTube = 2
}
export interface SegmentContainer {
2021-05-21 21:51:58 +02:00
segment: [number] | [number, number];
}
export interface SponsorTime extends SegmentContainer {
2021-04-06 05:35:05 +02:00
UUID: SegmentUUID;
locked?: number;
2021-04-06 05:35:05 +02:00
category: Category;
actionType: ActionType;
2021-10-13 05:33:41 +02:00
description?: string;
hidden?: SponsorHideType;
2021-12-26 06:17:49 +01:00
source: SponsorSourceType;
videoDuration?: number;
}
2021-09-02 01:51:42 +02:00
export interface ScheduledTime extends SponsorTime {
scheduledTime: number;
}
2021-01-17 18:56:37 +01:00
export interface PreviewBarOption {
2022-10-08 02:51:58 +02:00
color: string;
opacity: string;
2020-06-04 02:20:02 +02:00
}
2021-01-17 18:56:37 +01:00
export interface Registration {
2022-10-08 02:51:58 +02:00
message: string;
id: string;
allFrames: boolean;
js: string[];
css: string[];
2022-10-08 02:51:58 +02:00
matches: string[];
}
2021-01-17 18:56:37 +01:00
export interface BackgroundScriptContainer {
2022-10-08 02:51:58 +02:00
registerFirefoxContentScript: (opts: Registration) => void;
unregisterFirefoxContentScript: (id: string) => void;
}
2021-01-17 18:56:37 +01:00
export interface VideoInfo {
responseContext: {
2022-10-08 02:51:58 +02:00
serviceTrackingParams: Array<{service: string; params: Array<{key: string; value: string}>}>;
webResponseContextExtensionData: {
2022-10-08 02:51:58 +02:00
hasDecorated: boolean;
};
};
playabilityStatus: {
2022-10-08 02:51:58 +02:00
status: string;
playableInEmbed: boolean;
miniplayer: {
miniplayerRenderer: {
2022-10-08 02:51:58 +02:00
playbackMode: string;
};
};
};
streamingData: unknown;
playbackTracking: unknown;
videoDetails: {
2022-10-08 02:51:58 +02:00
videoId: string;
title: string;
lengthSeconds: string;
keywords: string[];
channelId: string;
isOwnerViewing: boolean;
shortDescription: string;
isCrawlable: boolean;
thumbnail: {
2022-10-08 02:51:58 +02:00
thumbnails: Array<{url: string; width: number; height: number}>;
};
averageRating: number;
allowRatings: boolean;
viewCount: string;
author: string;
isPrivate: boolean;
isUnpluggedCorpus: boolean;
isLiveContent: boolean;
};
playerConfig: unknown;
storyboards: unknown;
microformat: {
playerMicroformatRenderer: {
thumbnail: {
2022-10-08 02:51:58 +02:00
thumbnails: Array<{url: string; width: number; height: number}>;
};
embed: {
2022-10-08 02:51:58 +02:00
iframeUrl: string;
flashUrl: string;
width: number;
height: number;
flashSecureUrl: string;
};
title: {
2022-10-08 02:51:58 +02:00
simpleText: string;
};
description: {
2022-10-08 02:51:58 +02:00
simpleText: string;
};
lengthSeconds: string;
ownerProfileUrl: string;
externalChannelId: string;
availableCountries: string[];
isUnlisted: boolean;
hasYpcMetadata: boolean;
viewCount: string;
category: Category;
publishDate: string;
ownerChannelName: string;
uploadDate: string;
};
};
trackingParams: string;
attestation: unknown;
messages: unknown;
}
2021-01-17 18:56:37 +01:00
export type VideoID = string;
export type UnEncodedSegmentTimes = [string, SponsorTime[]][];
export enum ChannelIDStatus {
Fetching,
Found,
Failed
}
export interface ChannelIDInfo {
2022-10-08 02:51:58 +02:00
id: string;
status: ChannelIDStatus;
}
export interface SkipToTimeParams {
2022-10-08 02:51:58 +02:00
v: HTMLVideoElement;
skipTime: number[];
skippingSegments: SponsorTime[];
openNotice: boolean;
forceAutoSkip?: boolean;
unskipTime?: number;
}
export interface ToggleSkippable {
toggleSkip: () => void;
setShowKeybindHint: (show: boolean) => void;
}
export enum NoticeVisbilityMode {
FullSize = 0,
MiniForAutoSkip = 1,
MiniForAll = 2,
FadedForAutoSkip = 3,
FadedForAll = 4
}