Merge pull request #13 from bakkot/easier-download-link

Easier download link
This commit is contained in:
Simon 2022-12-03 20:37:46 +07:00 committed by GitHub
commit 5ae0a1baf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -215,6 +215,8 @@ function buildVideoButton(thumbContainer) {
let thumbLink = thumbContainer?.href;
if (!thumbLink) return;
if (thumbLink.includes('list=') || thumbLink.includes('/shorts/')) return;
let ggp = thumbContainer?.parentElement?.parentElement;
if (ggp?.id !== 'dismissible') return;
let dlButton = document.createElement('a');
dlButton.setAttribute('id', 'ta-video-button');
@ -226,14 +228,14 @@ function buildVideoButton(thumbContainer) {
console.log('download: ' + videoLink);
sendUrl(videoLink, 'download', dlButton);
});
dlButton.addEventListener('mouseover', e => {
ggp.addEventListener('mouseover', () => {
Object.assign(dlButton.style, {
opacity: 1,
});
let videoTitle = thumbContainer.href;
e.target.title = 'TA download: ' + videoTitle;
dlButton.title = 'TA download: ' + videoTitle;
});
dlButton.addEventListener('mouseout', () => {
ggp.addEventListener('mouseout', () => {
Object.assign(dlButton.style, {
opacity: 0,
});
@ -252,7 +254,6 @@ function buildVideoButton(thumbContainer) {
borderRadius: '8px',
cursor: 'pointer',
opacity: 0,
transition: 'all 0.3s ease 0.3s',
});
let dlIcon = document.createElement('span');