SponsorBlock/src/types.ts

161 lines
4.3 KiB
TypeScript
Raw Normal View History

2020-03-12 00:35:20 +01:00
import SubmissionNotice from "./render/SubmissionNotice";
import SkipNoticeComponent from "./components/SkipNoticeComponent";
2021-01-17 18:56:37 +01:00
export interface ContentContainer {
2020-03-12 00:35:20 +01:00
(): {
vote: (type: number, UUID: string, category?: string, skipNotice?: SkipNoticeComponent) => void,
2020-03-12 00:35:20 +01:00
dontShowNoticeAgain: () => void,
unskipSponsorTime: (segment: SponsorTime) => void,
sponsorTimes: SponsorTime[],
sponsorTimesSubmitting: SponsorTime[],
2020-03-12 00:35:20 +01:00
v: HTMLVideoElement,
sponsorVideoID,
reskipSponsorTime: (segment: SponsorTime) => void,
2020-03-12 00:35:20 +01:00
updatePreviewBar: () => void,
onMobileYouTube: boolean,
sponsorSubmissionNotice: SubmissionNotice,
resetSponsorSubmissionNotice: () => void,
changeStartSponsorButton: (showStartSponsor: boolean, uploadButtonVisible: boolean) => Promise<boolean>,
2020-09-15 16:26:46 +02:00
previewTime: (time: number, unpause?: boolean) => void,
videoInfo: VideoInfo,
getRealCurrentTime: () => number
2020-03-12 00:35:20 +01:00
}
}
2021-01-17 18:56:37 +01:00
export interface FetchResponse {
responseText: string,
status: number,
ok: boolean
}
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 {
ShowOverlay,
ManualSkip,
AutoSkip
}
2021-01-17 18:56:37 +01:00
export interface CategorySelection {
2020-04-03 04:13:36 +02:00
name: string;
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,
MinimumDuration
}
2021-01-17 18:56:37 +01:00
export interface SponsorTime {
segment: number[];
UUID: string;
category: string;
hidden?: SponsorHideType;
}
2021-01-17 18:56:37 +01:00
export interface PreviewBarOption {
2020-06-04 02:20:02 +02:00
color: string,
opacity: string
}
2021-01-17 18:56:37 +01:00
export interface Registration {
message: string,
id: string,
allFrames: boolean,
js: browser.extensionTypes.ExtensionFileOrCode[],
css: browser.extensionTypes.ExtensionFileOrCode[],
matches: string[]
}
2021-01-17 18:56:37 +01:00
export interface BackgroundScriptContainer {
registerFirefoxContentScript: (opts: Registration) => void,
unregisterFirefoxContentScript: (id: string) => void
}
2021-01-17 18:56:37 +01:00
export interface VideoInfo {
responseContext: {
serviceTrackingParams: Array<{service: string, params: Array<{key: string, value: string}>}>,
webResponseContextExtensionData: {
hasDecorated: boolean
}
},
playabilityStatus: {
status: string,
playableInEmbed: boolean,
miniplayer: {
miniplayerRenderer: {
playbackMode: string
}
}
};
streamingData: unknown;
playbackTracking: unknown;
videoDetails: {
videoId: string,
title: string,
lengthSeconds: string,
keywords: string[],
channelId: string,
isOwnerViewing: boolean,
shortDescription: string,
isCrawlable: boolean,
thumbnail: {
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: {
thumbnails: Array<{url: string, width: number, height: number}>
},
embed: {
iframeUrl: string,
flashUrl: string,
width: number,
height: number,
flashSecureUrl: string,
},
title: {
simpleText: string,
},
description: {
simpleText: string,
},
lengthSeconds: string,
ownerProfileUrl: string,
externalChannelId: string,
availableCountries: string[],
isUnlisted: boolean,
hasYpcMetadata: boolean,
viewCount: string,
category: string,
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 StorageChangesObject = { [key: string]: chrome.storage.StorageChange };
export type UnEncodedSegmentTimes = [string, SponsorTime[]][];