diff --git a/src/entries/contentScript/main.ts b/src/entries/contentScript/main.ts index fdbdd24..ca59546 100644 --- a/src/entries/contentScript/main.ts +++ b/src/entries/contentScript/main.ts @@ -1,5 +1,5 @@ -import {getMatch, type Match, MatchMediaType} from '~/lib/match'; -import {Other, Redirect} from '~/lib/settings'; +import { getMatch, type Match, MatchMediaType } from '~/lib/match'; +import { Other, Redirect } from '~/lib/settings'; async function main() { let match: Match | null; diff --git a/src/entries/player/player.ts b/src/entries/player/player.ts index b88fd98..5aba849 100644 --- a/src/entries/player/player.ts +++ b/src/entries/player/player.ts @@ -1,6 +1,6 @@ -import {matches, MatchMediaType} from '~/lib/match'; +import { matches, MatchMediaType } from '~/lib/match'; import Hls from 'hls.js'; -import {UrlReferer} from '~/lib/settings'; +import { UrlReferer } from '~/lib/settings'; async function playNative(url: string, domain: string, videoElem: HTMLVideoElement) { await UrlReferer.set(new URL(url).hostname, domain); diff --git a/src/lib/match.ts b/src/lib/match.ts index efeecd7..29be220 100644 --- a/src/lib/match.ts +++ b/src/lib/match.ts @@ -1,6 +1,6 @@ import { unpack } from './util/userspace'; import { Hosters, Redirect, TmpHost } from './settings'; -import {lastPathSegment} from "~/lib/util/extract"; +import { lastPathSegment } from '~/lib/util/extract'; export interface Match { name: string; @@ -10,12 +10,16 @@ export interface Match { regex: RegExp[]; notice?: string; - match(match: RegExpMatchArray): Promise; + match( + match: RegExpMatchArray + ): Promise< + string | { [MatchMediaType.Hls]: string } | { [MatchMediaType.Native]: string } | null + >; } export enum MatchMediaType { Hls = 'hls', - Native = 'native', + Native = 'native' } export const Doodstream: Match = { @@ -134,7 +138,7 @@ export const LoadX: Match = { const videoSource: string = responseJson['videoSource']; // extension of extracted url is '.txt', so we have to manually specify that it's a hls - return {[MatchMediaType.Hls]: videoSource.replace('\\/', '/')}; + return { [MatchMediaType.Hls]: videoSource.replace('\\/', '/') }; } }; diff --git a/src/lib/util/extract.ts b/src/lib/util/extract.ts index 6ebb4c7..7c429f0 100644 --- a/src/lib/util/extract.ts +++ b/src/lib/util/extract.ts @@ -1,6 +1,6 @@ export function lastPathSegment(path: string): string { - while (path.endsWith('/')) { - path = path.slice(0, -1); - } - return path.substring(path.lastIndexOf('/') + 1); + while (path.endsWith('/')) { + path = path.slice(0, -1); + } + return path.substring(path.lastIndexOf('/') + 1); }