mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-22 11:40:13 +00:00
better dl button naming
This commit is contained in:
parent
1fed4c32e2
commit
114548d362
@ -165,8 +165,8 @@ function buildChannelButton(channelContainer) {
|
|||||||
let spacer = buildSpacer();
|
let spacer = buildSpacer();
|
||||||
buttonDiv.appendChild(spacer);
|
buttonDiv.appendChild(spacer);
|
||||||
|
|
||||||
let dlLink = buildChannelDownloadLink();
|
let channelDownloadButton = buildChannelDownloadButton();
|
||||||
buttonDiv.appendChild(dlLink);
|
buttonDiv.appendChild(channelDownloadButton);
|
||||||
|
|
||||||
return buttonDiv;
|
return buttonDiv;
|
||||||
}
|
}
|
||||||
@ -233,36 +233,36 @@ function buildSpacer() {
|
|||||||
return spacer;
|
return spacer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildChannelDownloadLink() {
|
function buildChannelDownloadButton() {
|
||||||
let dlLink = document.createElement('span');
|
let channelDownloadButton = document.createElement('span');
|
||||||
let currentLocation = window.location.href;
|
let currentLocation = window.location.href;
|
||||||
let urlObj = new URL(currentLocation);
|
let urlObj = new URL(currentLocation);
|
||||||
|
|
||||||
if (urlObj.pathname.startsWith('/watch')) {
|
if (urlObj.pathname.startsWith('/watch')) {
|
||||||
let videoId = urlObj.search.split('=')[1];
|
let videoId = urlObj.search.split('=')[1];
|
||||||
dlLink.setAttribute('data-type', 'video');
|
channelDownloadButton.setAttribute('data-type', 'video');
|
||||||
dlLink.setAttribute('data-id', videoId);
|
channelDownloadButton.setAttribute('data-id', videoId);
|
||||||
dlLink.title = `TA download video: ${videoId}`;
|
channelDownloadButton.title = `TA download video: ${videoId}`;
|
||||||
} else {
|
} else {
|
||||||
let toDownload = urlObj.pathname.slice(1);
|
let toDownload = urlObj.pathname.slice(1);
|
||||||
dlLink.setAttribute('data-id', toDownload);
|
channelDownloadButton.setAttribute('data-id', toDownload);
|
||||||
dlLink.setAttribute('data-type', 'channel');
|
channelDownloadButton.setAttribute('data-type', 'channel');
|
||||||
dlLink.title = `TA download channel ${toDownload}`;
|
channelDownloadButton.title = `TA download channel ${toDownload}`;
|
||||||
}
|
}
|
||||||
dlLink.innerHTML = downloadIcon;
|
channelDownloadButton.innerHTML = downloadIcon;
|
||||||
dlLink.addEventListener('click', e => {
|
channelDownloadButton.addEventListener('click', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log(`download: ${currentLocation}`);
|
console.log(`download: ${currentLocation}`);
|
||||||
sendUrl(currentLocation, 'download', dlLink);
|
sendDownload(channelDownloadButton);
|
||||||
});
|
});
|
||||||
Object.assign(dlLink.style, {
|
Object.assign(channelDownloadButton.style, {
|
||||||
filter: 'invert()',
|
filter: 'invert()',
|
||||||
width: '20px',
|
width: '20px',
|
||||||
padding: '0 5px',
|
padding: '0 5px',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
});
|
});
|
||||||
|
|
||||||
return dlLink;
|
return channelDownloadButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTitleContainers() {
|
function getTitleContainers() {
|
||||||
|
Loading…
Reference in New Issue
Block a user