mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-05-09 20:25:14 +02:00
Update match function to manually specify media type
This commit is contained in:
parent
a9cf03c176
commit
416fceba88
@ -35,13 +35,28 @@ async function main() {
|
||||
}
|
||||
|
||||
let url: string | null;
|
||||
let urlType: 'hls' | 'native';
|
||||
try {
|
||||
url = await match.match(re);
|
||||
const matchResult = await match.match(re);
|
||||
if (matchResult && typeof matchResult === 'string') {
|
||||
url = matchResult;
|
||||
urlType = url.includes('.m3u8') ? 'hls' : 'native';
|
||||
} else if (matchResult && typeof matchResult === 'object') {
|
||||
if ('hls' in matchResult) {
|
||||
url = matchResult['hls'];
|
||||
urlType = 'hls';
|
||||
} else if ('native' in matchResult) {
|
||||
url = matchResult['native'];
|
||||
urlType = 'native';
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
if (!url || !urlType) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,7 +65,7 @@ async function main() {
|
||||
await chrome.runtime.sendMessage({ action: 'ff2mpv', url: url });
|
||||
}
|
||||
|
||||
if (match.replace && !url.includes('.m3u8')) {
|
||||
if (match.replace && urlType !== 'hls') {
|
||||
// this destroys all intervals that may spawn popups or events
|
||||
let intervalId = window.setInterval(() => {}, 0);
|
||||
while (intervalId--) {
|
||||
@ -81,7 +96,7 @@ async function main() {
|
||||
chrome.runtime.getURL(
|
||||
`src/entries/player/player.html?id=${match.id}&url=${encodeURIComponent(url)}&domain=${
|
||||
window.location.hostname
|
||||
}`
|
||||
}&type=${urlType}`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ export async function play(videoElem: HTMLVideoElement) {
|
||||
const id = urlQuery.get('id') as string;
|
||||
const url = decodeURIComponent(urlQuery.get('url') as string);
|
||||
const domain = urlQuery.get('domain') as string;
|
||||
const urlType = urlQuery.get('urlType') as string;
|
||||
|
||||
const match = matches[id];
|
||||
if (match === undefined) {
|
||||
@ -38,9 +39,9 @@ export async function play(videoElem: HTMLVideoElement) {
|
||||
}
|
||||
document.title = `Stream Bypass (${domain})`;
|
||||
|
||||
if (new URL(url).pathname.endsWith('.m3u8')) {
|
||||
if (urlType === 'hls') {
|
||||
await playHls(url, domain, videoElem);
|
||||
} else {
|
||||
} else if (urlType === 'native') {
|
||||
await playNative(url, domain, videoElem);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ export interface Match {
|
||||
regex: RegExp[];
|
||||
notice?: string;
|
||||
|
||||
match(match: RegExpMatchArray): Promise<string | null>;
|
||||
match(match: RegExpMatchArray): Promise<string | { hls: string } | { native: string } | null>;
|
||||
}
|
||||
|
||||
export const Doodstream: Match = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user