-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpr.html
122 lines (106 loc) · 3.73 KB
/
dpr.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Teste</title>
<style>
html {
width: 100%;
height: 100%;
}
body {
display: flex;
align-items: center;
flex-direction: column;
margin: auto;
width: 100%;
height: 100%;
justify-content: center;
}
</style>
</head>
<body>
<img
src="https://emojipedia-us.s3.amazonaws.com/source/microsoft-teams/337/index-pointing-up_261d-fe0f.png"
alt="pointing"
/>
<script>
const youtubeLinks = {
videoLong: "www.youtube.com/watch?v=",
channel: "www.youtube.com/c/",
videoShort: "https://youtu.be/",
https: "https://",
www: "www.",
};
const full_url =
"https://www.youtube.com/watch?v=1ENiVwk8idM&ab_channel=Fireship";
const searchParams = new URLSearchParams(full_url.split("?")[1]);
function buildChannelURL(channelFallback) {
if (channelFallback.includes(youtubeLinks.https)) {
if (channelFallback.includes(youtubeLinks.www)) {
return channelFallback.replace(
youtubeLinks.https,
youtubeLinks.www
);
}
return channelFallback.replace(youtubeLinks.https, "");
} else if (!channelFallback.includes(youtubeLinks.www)) {
return youtubeLinks.channel + channelFallback;
}
return channelFallback;
}
function buildVideoURL(fallbackURL) {
if (fallbackURL.includes(youtubeLinks.videoShort)) {
const videoId = fallbackURL.split(youtubeLinks.videoShort)[1];
return youtubeLinks.videoLong + videoId;
} else if (fallbackURL.includes(youtubeLinks.https)) {
if (fallbackURL.includes(youtubeLinks.www)) {
return fallbackURL.replace(youtubeLinks.https, youtubeLinks.www);
}
return fallbackURL.replace(youtubeLinks.https, "");
} else if (!fallbackURL.includes(youtubeLinks.www)) {
return youtubeLinks.videoLong + fallbackURL;
}
return fallbackURL;
}
function getFallbackURL(searchParams) {
const fallbackURL = searchParams.get("u") ?? searchParams.get("v");
const channelFallback = searchParams.get("c") ?? searchParams.get("c");
if (channelFallback) {
return buildChannelURL(channelFallback);
} else if (fallbackURL) {
return buildVideoURL(fallbackURL);
}
return null;
}
const fallbackURL = getFallbackURL(searchParams);
const redirectUrls = {
androidApp: `intent://${fallbackURL}#Intent;package=com.google.android.youtube;scheme=https;end`,
iosApp: `vnd.youtube://${fallbackURL}`,
browser: `https://${fallbackURL}`,
};
// alert(redirectUrls.androidApp);
const isIOS = /iPhone|iPad|iPod/i.test(navigator.userAgent);
const isAndroid = /Android/i.test(navigator.userAgent);
if (isIOS) {
window.location.href = redirectUrls.iosApp;
window.setTimeout(function () {
window.location.href = `https://${fallbackURL}`;
}, 25);
} else if (isAndroid) {
window.location.href = redirectUrls.androidApp;
window.setTimeout(function () {
window.location.href = `https://${fallbackURL}`;
}, 25);
} else {
window.location.href = redirectUrls.browser;
}
function killPopup() {
window.removeEventListener("pagehide", killPopup);
}
window.addEventListener("pagehide", killPopup);
</script>
</body>
</html>