-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
57 lines (53 loc) · 1.71 KB
/
script.js
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
function youtube_thumbnail_downloader(url) {
regExp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
match = url.match(regExp);
if (match && match[1].length == 11) {
vidurl = match[1];
thumbnailpreview = "http://img.youtube.com/vi/" + vidurl + "/mqdefault.jpg";
thumbnailhd = "http://img.youtube.com/vi/" + vidurl + "/maxresdefault.jpg";
thumbnailmd = "http://img.youtube.com/vi/" + vidurl + "/hqdefault.jpg";
thumbnaillow = "http://img.youtube.com/vi/" + vidurl + "/mqdefault.jpg";
} else {
alert(
"The URL you have entered maybe incorrect. Please Enter a correct URL."
);
location.reload();
}
document.getElementById("thumbnailpreview").src = thumbnailpreview;
document.getElementById("thumbnailhd").href = thumbnailhd;
document.getElementById("thumbnailmd").href = thumbnailmd;
document.getElementById("thumbnaillow").href = thumbnaillow;
}
$(document).keypress(function (event) {
if (
(event.which == 115 && (event.ctrlKey || event.metaKey)) ||
event.which == 19
) {
event.preventDefault();
return false;
}
if (keyCode == 13) {
$("#thumbdloadbtn").trigger("click");
}
return true;
});
$("#download-buttons").hide();
$("#thumbdloadbtn").click(function () {
$("#download-buttons").slideDown(500).fadeIn(250);
$("#thumbdloadbtn").hide();
$(".input-group").hide();
});
// Replace source
$("img").error(function () {
$(this).attr("src", "#.png");
});
// Or, hide them
$("img").error(function () {
$(this).hide();
});
$("#ytlink").keydown(function (e) {
var keyCode = e.keyCode ? e.keyCode : e.which;
if (keyCode == 13) {
$("#thumbdloadbtn").trigger("click");
}
});