mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-06-28 02:50:32 +02:00
Fix vidmoly.to
This commit is contained in:
@ -1,23 +1,23 @@
|
||||
import './shared';
|
||||
|
||||
import type { Match } from '~/lib/match';
|
||||
import { Redirect, storageDelete, storageGet } from '~/lib/settings';
|
||||
import { Redirect, UrlReferer } from '~/lib/settings';
|
||||
import { getMatch } from '~/lib/match';
|
||||
|
||||
chrome.webRequest.onBeforeSendHeaders.addListener(
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
async (details) => {
|
||||
const referer: { domain: string } | undefined = await storageGet('referer');
|
||||
if (referer === undefined) return;
|
||||
const referer = await UrlReferer.get(new URL(details.url).hostname);
|
||||
if (!referer) return;
|
||||
|
||||
await UrlReferer.delete(new URL(details.url).hostname);
|
||||
|
||||
details.requestHeaders!.push({
|
||||
name: 'Referer',
|
||||
value: `https://${referer.domain}/`
|
||||
value: `https://${referer}/`
|
||||
});
|
||||
|
||||
await storageDelete('referer');
|
||||
|
||||
return { requestHeaders: details.requestHeaders };
|
||||
},
|
||||
{ urls: ['<all_urls>'], types: ['xmlhttprequest'] },
|
||||
|
@ -1,17 +1,23 @@
|
||||
import { matches } from '~/lib/match';
|
||||
import Hls from 'hls.js';
|
||||
import { storageSet } 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);
|
||||
|
||||
async function playNative(url: string, videoElem: HTMLVideoElement) {
|
||||
videoElem.src = url;
|
||||
}
|
||||
|
||||
async function playHls(url: string, videoElem: HTMLVideoElement) {
|
||||
async function playHls(url: string, domain: string, videoElem: HTMLVideoElement) {
|
||||
if (videoElem.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
videoElem.src = url;
|
||||
} else if (Hls.isSupported()) {
|
||||
const hls = new Hls({
|
||||
enableWorker: false
|
||||
enableWorker: false,
|
||||
xhrSetup: async (xhr: XMLHttpRequest, url: string) => {
|
||||
await UrlReferer.set(new URL(url).hostname, domain);
|
||||
xhr.open('GET', url);
|
||||
}
|
||||
});
|
||||
hls.loadSource(url);
|
||||
hls.attachMedia(videoElem);
|
||||
@ -32,11 +38,9 @@ export async function play(videoElem: HTMLVideoElement) {
|
||||
}
|
||||
document.title = `Stream Bypass (${domain})`;
|
||||
|
||||
await storageSet('referer', { domain: domain });
|
||||
|
||||
if (new URL(url).pathname.endsWith('.m3u8')) {
|
||||
await playHls(url, videoElem);
|
||||
await playHls(url, domain, videoElem);
|
||||
} else {
|
||||
await playNative(url, videoElem);
|
||||
await playNative(url, domain, videoElem);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user