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