2 new websites + indicator for redirect reliability

This commit is contained in:
2021-10-23 17:02:09 +02:00
parent 99d4577d1d
commit 0916f1c637
12 changed files with 195 additions and 33 deletions

View File

@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<link rel="stylesheet" href="/res/hls.css">
<title>m3u8</title>
<link rel="stylesheet" href="/res/hls.css">
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body style="margin: 0">
<video id="video" style="width: 100%; height: 100%"></video>
<p id="not-supported" hidden>Filed to play m3u8 video. Try again or create a new issue <a href="https://github.com/ByteDream/stream-bypass/issues">here</a></p>
<body>
<video id="video"></video>
<p id="message" hidden></p>
<script src="/res/hls.js"></script>
</body>
</html>

View File

@ -1,6 +1,9 @@
html, body, video
height: 100%
width: 100%
height: 100%
margin: 0
video
margin: auto
position: absolute
top: 0
left: 0

View File

@ -1,3 +1,10 @@
function showMessage(message: string) {
let messageElement = document.getElementById('message') as HTMLParagraphElement
messageElement.innerHTML = message
messageElement.hidden = false
document.getElementById('video').hidden = true
}
function loadHls() {
let url = window.location.hash.substring(1)
let video = document.getElementById('video') as HTMLVideoElement;
@ -11,9 +18,42 @@ function loadHls() {
let hls = new Hls()
hls.loadSource(url)
hls.attachMedia(video)
let searchParams = new URLSearchParams(window.location.search)
let rawReliability = parseInt(searchParams.get('reliability'))
let thirdPartyFallback = setTimeout(() => {
let message: string
switch (rawReliability) {
case 1: // low
message = `The reliability for this domain is low, so errors like this are common.
Try to choose another streaming provider (if existent) or deactivate the addon for this domain (${searchParams.get('domain')}) and try again`
break
case 2: // normal
message = `The reliability for this domain is normal, errors like this can occur but are not very common. Try to refresh the page`
break
case 3: // high
message = `The reliability for this domains is high, errors like this are very unlikely to happen.
Try to refresh the page and if the error still exists you might want to open a new issue <a href="https://github.com/ByteDream/stream-bypass/issues">here</a>.
When your using <a href="https://www.torproject.org/">Tor</a> such errors have a slight chance to occur more often,
so if this is the case just try to reload the page and see if you it's working then`
break
}
// shows a message if hls could not be loaded
showMessage(`Could not load hls video. ${message}`)
}, rawReliability * 3000)
// @ts-ignore
hls.on(Hls.Events.MANIFEST_PARSED, () => {
clearTimeout(thirdPartyFallback)
document.getElementById('video').hidden = false
document.getElementById('message').hidden = true
})
} else {
// shows a message if hls is not supported
document.getElementById('not-supported').hidden = false
showMessage(`Failed to play m3u8 video (hls is not supported). Try again or create a new issue <a href="https://github.com/ByteDream/stream-bypass/issues">here</a>`)
}
}