-
Notifications
You must be signed in to change notification settings - Fork 3
/
youtube_player.html
48 lines (48 loc) · 1.81 KB
/
youtube_player.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
<!DOCTYPE html>
<html lang = "en">
<head>
<title>YouTube Player</title>
<style>
html, body {
height: 100%;
margin: 0;
}
</style>
</head>
<body>
<script>
const params = new URLSearchParams (window.location.search);
if (params.get ("video") === null) {
video = prompt ("Enter the YouTube URL or Video ID:").slice (-11);
url = "https://cyrilsli.github.io/youtube_player?video=" + video + "&rel=0&playlist=" + video;
if (! confirm ("OPTIONAL: Press 'Cancel' for no visible controls on the video or 'OK' to continue: ")) {
url += "&controls=0";
}
if (! confirm ("OPTIONAL: Press 'Cancel' for no keyboard controls on the video or 'OK' to continue: ")) {
url += "&disablekb=1";
}
if (! confirm ("OPTIONAL: Press 'Cancel' to loop the video or 'OK' to continue: ")) {
url += "&loop=1";
}
start = prompt ("OPTIONAL: Enter the time IN SECONDS when you want the video to start, leave blank to start at the beginning:");
if (start !== "") {
url += "&start=" + start;
}
end = prompt ("OPTIONAL: Enter the time IN SECONDS when you want the video to stop, leave blank to stop at the end:");
if (end !== "") {
url += "&end=" + end;
}
console.log (url);
open (url, "_self");
} else {
frame = document.createElement ("iframe");
frame.setAttribute ("width", "100%");
frame.setAttribute ("height", "100%");
frame.setAttribute ("frameBorder", "0");
url = "https://www.youtube-nocookie.com/embed/" + window.location.href.split ("video=") [1].replace ("&", "?");
console.log (url);
frame.setAttribute ("src", url);
document.body.appendChild (frame);
}
</script>
</body>