Compare commits

...

3 Commits

Author SHA1 Message Date
Simon 9ba90e4e45
bump version 1 month ago
Simon 0d58ddaaa2
limit cookie domains, #22 (#38) 1 month ago
Vladimir Pouzanov c82e493628
Relocate the injected button to the h3 element (#37) 1 month ago

@ -208,6 +208,7 @@ function buildCookieLine(cookie) {
async function sendCookies() {
console.log('function sendCookies');
const acceptableDomains = ['.youtube.com', 'youtube.com', 'www.youtube.com'];
let cookieStores = await browserType.cookies.getAllCookieStores();
let cookieLines = [
@ -223,7 +224,9 @@ async function sendCookies() {
});
for (let j = 0; j < allCookiesStore.length; j++) {
const cookie = allCookiesStore[j];
cookieLines.push(buildCookieLine(cookie));
if (acceptableDomains.includes(cookie.domain)) {
cookieLines.push(buildCookieLine(cookie));
}
}
}

@ -14,7 +14,7 @@
<a href="#" id="ta-url" target="_blank">
<img src="/images/logo.png" alt="ta-logo">
</a>
<span>v0.2.2</span>
<span>v0.3.0</span>
</div>
<hr>
<form class="login-form">

@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "TubeArchivist Companion",
"description": "Interact with your selfhosted TA server.",
"version": "0.2.2",
"version": "0.3.0",
"icons": {
"48": "/images/icon.png",
"128": "/images/icon128.png"

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "TubeArchivist Companion",
"description": "Interact with your selfhosted TA server.",
"version": "0.2.2",
"version": "0.3.0",
"icons": {
"128": "/images/icon128.png"
},

@ -135,12 +135,14 @@ function ensureTALinks() {
let titleContainerNodes = getTitleContainers();
for (let titleContainer of titleContainerNodes) {
if (titleContainer.hasTA) continue;
let parent = getNearestH3(titleContainer);
if (!parent) continue;
if (parent.hasTA) continue;
let videoButton = buildVideoButton(titleContainer);
if (videoButton == null) continue;
processTitle(titleContainer);
titleContainer.appendChild(videoButton);
titleContainer.hasTA = true;
processTitle(parent);
parent.appendChild(videoButton);
parent.hasTA = true;
}
}
ensureTALinks = throttled(ensureTALinks, 700);
@ -329,6 +331,8 @@ function getTitleContainers() {
}
function getVideoId(titleContainer) {
if (!titleContainer) return undefined;
let href = getNearestLink(titleContainer);
if (!href) return;
@ -394,6 +398,16 @@ function getNearestLink(element) {
return null;
}
function getNearestH3(element) {
for (let i = 0; i < 5 && element && element !== document; i++) {
if (element.tagName === 'H3') {
return element;
}
element = element.parentNode;
}
return null;
}
function processTitle(titleContainer) {
if (titleContainer.hasListener) return;
Object.assign(titleContainer.style, {
@ -439,9 +453,9 @@ function checkVideoExists(taButton) {
console.error(e);
}
let videoId = taButton.dataset.id;
if (taButton.parentElement) {
videoId = getVideoId(taButton.parentElement);
let aElem = taButton?.parentElement?.querySelector('a');
let videoId = getVideoId(aElem);;
if (aElem) {
taButton.setAttribute('data-id', videoId);
taButton.setAttribute('data-type', 'video');
taButton.title = `TA download video: ${taButton.parentElement.innerText} [${videoId}]`;

Loading…
Cancel
Save