-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
youtube_getVideoThumbnail.js
51 lines (47 loc) · 1.35 KB
/
youtube_getVideoThumbnail.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
import { getIdFromYoutubeURL } from "./youtube_downloadVideo.js";
export default {
icon: '<i class="fa-regular fa-image fa-lg"></i>',
name: {
en: "Get Youtube video's thumbnail",
vi: "Lấy thumbnail video trên Youtube",
},
description: {
en: "Get largest thumbnail of playing youtube video",
vi: "Tải về hình thumbnail độ phân giải lớn nhất của video youtube đang xem",
},
changeLogs: {
"2024-07-04": "init",
},
whiteList: ["https://*.youtube.com/*"],
pageScript: {
onClick: () => {
const methods = [
() =>
document
.getElementsByTagName("ytd-app")[0]
.data.playerResponse.videoDetails.thumbnail.thumbnails.sort(
(a, b) => b.width * b.height - a.width * a.height
)[0].url,
() =>
ytplayer.config.args.raw_player_response.videoDetails.thumbnail.thumbnails.sort(
(a, b) => b.width * b.height - a.width * a.height
)[0].url,
() =>
`https://i.ytimg.com/vi/${getIdFromYoutubeURL(
location.href
)}/maxresdefault.jpg`,
];
for (let f of methods) {
try {
let url = f();
if (url) {
window.open(url, "_blank");
return;
}
} catch (e) {
console.error(e);
}
}
},
},
};