update app code

This commit is contained in:
Alexander Popov 2022-09-25 01:29:55 +03:00
parent 4743da6fae
commit bde6b9ee05
Signed by: iiiypuk
GPG Key ID: D8C9B59A9F04A70C
6 changed files with 21 additions and 13 deletions

View File

View File

@ -1,13 +0,0 @@
function getCover()
{
var videoUrl = document.getElementById('videoUrl').value;
var videoCover = new Image();
videoCover.onload = function()
{
document.getElementById('ytImage').innerHTML =
'<a title="' + videoCover.width + 'x' + videoCover.height + '" href="' + videoCover.src + '" download="cover"><img src="'+ videoCover.src +'"></a>';
}
videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg';
}

21
src/ytcg.js Normal file
View File

@ -0,0 +1,21 @@
function getCover()
{
'use strict';
let videoUrl = document.getElementById('videoUrl').value;
let imageDiv = document.getElementById('ytImage');
imageDiv.innerHTML = '';
let videoCover = document.createElement('img');
let imageLink = document.createElement('a');
videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg';
imageLink.href = videoCover.src;
imageLink.download = 'cover';
videoCover.onload = function() {
imageLink.title = videoCover.width + 'x' + videoCover.height;
}
imageLink.appendChild(videoCover);
imageDiv.appendChild(imageLink);
}