-
Notifications
You must be signed in to change notification settings - Fork 0
/
yt.html
73 lines (67 loc) · 2.39 KB
/
yt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
var youtubeVideoLongLink = 'www.youtube.com/watch?v=';
var youtubeChannelLink = 'www.youtube.com/c/';
var youtubeShortLink = 'https://youtu.be/';
var https = 'https://';
var www = 'www.';
var fallbackURL = getParameterByName('u');
var channelFallback = getParameterByName('c');
if (channelFallback) {
if (channelFallback.includes(https)) {
if (channelFallback.includes(www))
fallbackURL = channelFallback.replace((https, ''));
else fallbackURL = channelFallback.replace(https, www);
} else if (!channelFallback.includes(www)) {
fallbackURL = youtubeChannelLink + channelFallback;
}
} else if (fallbackURL) {
if (fallbackURL.includes(youtubeShortLink)) {
fallbackURL =
youtubeVideoLongLink + fallbackURL.split(youtubeShortLink)[1];
} else if (fallbackURL.includes(https)) {
if (fallbackURL.includes(www))
fallbackURL = fallbackURL.replace((https, ''));
else fallbackURL = fallbackURL.replace(https, www);
} else if (!fallbackURL.includes(www)) {
fallbackURL = youtubeVideoLongLink + fallbackURL;
}
} else return;
var androidApp = `intent://${fallbackURL}#Intent;package=com.google.android.youtube;scheme=https;end`;
var iosApp = `vnd.youtube://${fallbackURL}`;
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
window.location.href = iosApp;
window.setTimeout(function () {
window.location.href = https + fallbackURL;
}, 25);
} else if (/Android/i.test(navigator.userAgent)) {
window.location.href = androidApp;
window.setTimeout(function () {
window.location.href = https + fallbackURL;
}, 25);
} else {
window.location.href = https + fallbackURL;
}
function killPopup() {
window.removeEventListener('pagehide', killPopup);
}
window.addEventListener('pagehide', killPopup);
};
</script>
</body>
</html>