feat(a11y): add skip-to-categories link at page top and sidebar shortcut (v1.6.4)

This commit is contained in:
Enes Yakıştır
2026-10-18 22:58:25 +03:00
parent 96140bca5e
commit 333383442f
3 changed files with 151 additions and 2 deletions
+103
View File
@@ -3365,6 +3365,101 @@ try {
} }
} }
function jumpToCategories() {
var bar = document.getElementById('yaktube-category-chips-bar');
if (bar) {
var activeOrFirst =
bar.querySelector('.yaktube-category-chip.active') || bar.querySelector('.yaktube-category-chip');
if (activeOrFirst) {
activeOrFirst.focus();
try {
activeOrFirst.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
} catch (e) {}
announce('Kategori çubuğuna odaklanıldı: ' + (activeOrFirst.textContent || 'Tümü'));
return true;
}
}
// If categories bar is not on current page (e.g. watch page), navigate to browse
window.location.href = '/videos/browse';
return false;
}
function injectSkipToCategoriesLink() {
if (document.getElementById('yaktube-skip-to-categories')) return;
var skipContent = document.querySelector('.skip-to-content, a[href*="content"]');
var toggleBtn = document.querySelector('.toggle-menu, button[title*="Yanal"], button[aria-label*="Yanal"]');
var skipLink = document.createElement('a');
skipLink.id = 'yaktube-skip-to-categories';
skipLink.href = '#yaktube-category-chips-bar';
skipLink.className = 'visually-hidden-focusable skip-to-content yaktube-skip-categories';
skipLink.setAttribute('aria-label', 'Kategorilere atla');
skipLink.textContent = 'Kategorilere atla';
skipLink.addEventListener('click', function (e) {
e.preventDefault();
jumpToCategories();
});
skipLink.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
jumpToCategories();
}
});
if (skipContent && skipContent.parentElement) {
skipContent.parentElement.insertBefore(skipLink, skipContent.nextSibling);
} else if (toggleBtn && toggleBtn.parentElement) {
toggleBtn.parentElement.insertBefore(skipLink, toggleBtn);
} else {
document.body.prepend(skipLink);
}
}
function injectSidebarCategoriesLink() {
if (document.getElementById('yaktube-sidebar-categories-link')) return;
var menuContainer = document.querySelector('my-menu .quick-access, my-menu ul, .main-menu ul');
if (!menuContainer) return;
var li = document.createElement('li');
li.className = 'menu-item yaktube-menu-categories-item';
var link = document.createElement('a');
link.id = 'yaktube-sidebar-categories-link';
link.href = '#yaktube-category-chips-bar';
link.className = 'menu-link item-link yaktube-menu-categories-link';
link.setAttribute('role', 'button');
link.setAttribute('aria-label', 'Video kategorilerine atla');
link.innerHTML =
'<span aria-hidden="true" style="font-size: 16px; margin-right: 8px;">🏷️</span> <span>Kategorilere atla</span>';
link.addEventListener('click', function (e) {
e.preventDefault();
jumpToCategories();
});
link.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
jumpToCategories();
}
});
li.appendChild(link);
var firstLi = menuContainer.querySelector('li');
if (firstLi && firstLi.nextSibling) {
menuContainer.insertBefore(li, firstLi.nextSibling);
} else if (firstLi) {
menuContainer.appendChild(li);
} else {
menuContainer.prepend(li);
}
}
// Pre-fetch guest import quota setting quietly on startup // Pre-fetch guest import quota setting quietly on startup
setTimeout(function () { setTimeout(function () {
fetchGuestImportLimit(); fetchGuestImportLimit();
@@ -5631,6 +5726,14 @@ try {
injectCategoryChipsBar(); injectCategoryChipsBar();
} catch (e) {} } catch (e) {}
try {
injectSkipToCategoriesLink();
} catch (e) {}
try {
injectSidebarCategoriesLink();
} catch (e) {}
try { try {
checkAndInjectRelatedVideos(Boolean(isNav)); checkAndInjectRelatedVideos(Boolean(isNav));
} catch (e) {} } catch (e) {}
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.6.3", "version": "1.6.4",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
"main": "main.js", "main": "main.js",
"library": "./main.js", "library": "./main.js",
+47 -1
View File
@@ -1633,7 +1633,7 @@ my-date-toggle .date-toggle:focus-visible {
} }
.yaktube-category-chip.active, .yaktube-category-chip.active,
.yaktube-category-chip[aria-selected="true"] { .yaktube-category-chip[aria-selected='true'] {
background: #ff8f37 !important; background: #ff8f37 !important;
color: #000000 !important; color: #000000 !important;
font-weight: 800 !important; font-weight: 800 !important;
@@ -1681,3 +1681,49 @@ my-date-toggle .date-toggle:focus-visible {
} }
} }
/* Skip to Categories button & Sidebar shortcut */
.yaktube-skip-categories {
position: absolute !important;
top: 10px !important;
left: 160px !important;
z-index: 100000 !important;
background: #ff8f37 !important;
color: #000000 !important;
padding: 8px 16px !important;
border-radius: 6px !important;
font-weight: 800 !important;
text-decoration: none !important;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important;
}
.yaktube-skip-categories:not(:focus):not(:focus-within) {
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0, 0, 0, 0) !important;
white-space: nowrap !important;
border: 0 !important;
}
.yaktube-menu-categories-item {
margin: 4px 0;
}
.yaktube-menu-categories-link {
display: flex !important;
align-items: center !important;
gap: 10px !important;
font-weight: 600 !important;
color: #ff8f37 !important;
cursor: pointer !important;
border-radius: 8px !important;
transition: background-color 0.15s ease !important;
}
.yaktube-menu-categories-link:hover,
.yaktube-menu-categories-link:focus-visible {
background-color: rgba(255, 143, 55, 0.15) !important;
outline: 2px solid #ff8f37 !important;
}