mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-05-09 20:25:14 +02:00
Redirect to custom video player on every url
This commit is contained in:
parent
9b4bcc6c64
commit
8990e25a72
@ -3,8 +3,8 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>HLS</title>
|
||||
<link rel="stylesheet" href="hls.css">
|
||||
<script src="hls.js" defer></script>
|
||||
<link rel="stylesheet" href="player.css">
|
||||
<script src="player.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<video id="video"></video>
|
@ -1,4 +1,4 @@
|
||||
import {matches, Reliability} from "../../match/match";
|
||||
import {Match, matches, Reliability} from "../../match/match";
|
||||
// @ts-ignore
|
||||
import Hls from "hls.js";
|
||||
|
||||
@ -8,18 +8,13 @@ function show_message(message: string) {
|
||||
document.getElementById('video').hidden = true
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const urlQuery = new URLSearchParams(window.location.search)
|
||||
const id = urlQuery.get('id')
|
||||
const url = urlQuery.get('url')
|
||||
|
||||
const match = matches.find((m) => m.id === id)
|
||||
if (match === undefined) {
|
||||
show_message(`Invalid id: ${id}. Please report this <a href="https://github.com/ByteDream/stream-bypass/issues/new">here</a>`)
|
||||
return
|
||||
}
|
||||
document.title = match.name
|
||||
async function play_native(url: string, match: Match) {
|
||||
const video = document.getElementById('video') as HTMLVideoElement
|
||||
video.controls = true
|
||||
video.src = url
|
||||
}
|
||||
|
||||
async function play_hls(url: string, match: Match) {
|
||||
const video = document.getElementById('video') as HTMLVideoElement
|
||||
video.controls = true
|
||||
|
||||
@ -66,4 +61,19 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const urlQuery = new URLSearchParams(window.location.search)
|
||||
const id = urlQuery.get('id')
|
||||
const url = urlQuery.get('url')
|
||||
|
||||
const match = matches.find((m) => m.id === id)
|
||||
if (match === undefined) {
|
||||
show_message(`Invalid id: ${id}. Please report this <a href="https://github.com/ByteDream/stream-bypass/issues/new">here</a>`)
|
||||
return
|
||||
}
|
||||
document.title = match.name
|
||||
|
||||
url.endsWith('.m3u8') ? await play_hls(url, match) : await play_native(url, match)
|
||||
}
|
||||
|
||||
main()
|
@ -80,7 +80,7 @@ async function buildMisc() {
|
||||
async function buildHtml() {
|
||||
const files = {
|
||||
'src/ui/popup/popup.html': 'build/ui/popup/popup.html',
|
||||
'src/ui/hls/hls.html': 'build/ui/hls/hls.html'
|
||||
'src/ui/player/player.html': 'build/ui/player/player.html'
|
||||
}
|
||||
|
||||
for (const [src, dst] of Object.entries(files)) {
|
||||
@ -92,7 +92,7 @@ async function buildHtml() {
|
||||
async function buildCss() {
|
||||
const files = {
|
||||
'src/ui/popup/popup.sass': 'build/ui/popup/popup.css',
|
||||
'src/ui/hls/hls.sass': 'build/ui/hls/hls.css'
|
||||
'src/ui/player/player.sass': 'build/ui/player/player.css'
|
||||
}
|
||||
|
||||
for (const [src, dst] of Object.entries(files)) {
|
||||
@ -108,7 +108,7 @@ async function buildCss() {
|
||||
async function buildJs() {
|
||||
const files = {
|
||||
'src/ui/popup/popup.ts': 'build/ui/popup/popup.js',
|
||||
'src/ui/hls/hls.ts': 'build/ui/hls/hls.js',
|
||||
'src/ui/player/player.ts': 'build/ui/player/player.js',
|
||||
|
||||
'src/index.ts': 'build/index.js'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user