videos = {
const root = md([SELECTION]);
const as = Array.from(root.querySelectorAll('a[href^="https://www.youtube.com/watch?v="][title]'));
const videos = as.filter((_, i) => i < 1).map((a) => ({
href: a.href,
id: (new URL(a.href)).searchParams.get('v'),
title: a.title,
transcript: null,
}));
for (const video of videos) {
const transcript = await TRANSCRIPT(video.id);
video.transcript = transcript;
}
return videos;
async function TRANSCRIPT(id) {
const response = await fetch(`https://youtube.is.mediocreatbest.xyz/transcript/${id}`, {
mode: 'cors',
headers: {
'Accept': 'application/json',
'Authorization': `Basic ${btoa(AUTH)}`,
},
});
const json = await response.json();
return json;
};
};