mirror of
https://github.com/tubearchivist/browser-extension.git
synced 2024-11-05 03:30:12 +00:00
implement open in TA
This commit is contained in:
parent
1306dbd6fa
commit
f3064f32b1
@ -138,7 +138,9 @@ async function subscribe(url, subscribed) {
|
||||
async function videoExists(id) {
|
||||
const path = `api/video/${id}/`;
|
||||
let response = await sendGet(path);
|
||||
return Boolean(response.data);
|
||||
if (!response.data) return false;
|
||||
let access = await getAccess();
|
||||
return new URL(`video/${id}/`, access.url).href;
|
||||
}
|
||||
|
||||
async function getChannelCache() {
|
||||
|
@ -278,6 +278,7 @@ function buildChannelDownloadButton() {
|
||||
channelDownloadButton.setAttribute('data-type', 'video');
|
||||
channelDownloadButton.setAttribute('data-id', videoId);
|
||||
channelDownloadButton.title = `TA download video: ${videoId}`;
|
||||
checkVideoExists(channelDownloadButton);
|
||||
} else {
|
||||
let toDownload = urlObj.pathname.slice(1);
|
||||
channelDownloadButton.setAttribute('data-id', toDownload);
|
||||
@ -386,9 +387,14 @@ function processTitle(titleContainer) {
|
||||
|
||||
function checkVideoExists(taButton) {
|
||||
function handleResponse(message) {
|
||||
let buttonSpan = taButton.querySelector('span');
|
||||
if (message) {
|
||||
let buttonSpan = taButton.querySelector('span') || taButton;
|
||||
if (message !== false) {
|
||||
buttonSpan.innerHTML = checkmarkIcon;
|
||||
buttonSpan.title = 'Open in TA';
|
||||
buttonSpan.addEventListener('click', () => {
|
||||
let win = window.open(message, '_blank');
|
||||
win.focus();
|
||||
});
|
||||
} else {
|
||||
buttonSpan.innerHTML = downloadIcon;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user