fix(a11y): place skip-to-categories strictly after skip-to-content (v1.6.5)

This commit is contained in:
Enes Yakıştır
2026-10-18 23:10:59 +03:00
parent 333383442f
commit 503408e641
2 changed files with 48 additions and 33 deletions
+47 -32
View File
@@ -2136,7 +2136,17 @@ try {
e.preventDefault(); e.preventDefault();
focusVideoPlayer(); focusVideoPlayer();
}); });
document.body.insertBefore(skipLink, document.body.firstChild); }
if (skipLink && !isEmbedUrl()) {
var skipContent = document.querySelector('.skip-to-content, a[href*="content"]');
if (skipContent) {
if (skipContent.nextElementSibling !== skipLink) {
skipContent.insertAdjacentElement('afterend', skipLink);
}
} else if (skipLink.parentElement !== document.body) {
document.body.insertBefore(skipLink, document.body.firstChild);
}
} }
// 4. Configure Player Container (#videojs-wrapper or .video-js or #video-wrapper) // 4. Configure Player Container (#videojs-wrapper or .video-js or #video-wrapper)
@@ -3155,7 +3165,7 @@ try {
} }
} }
function injectCategoryChipsBar() { function isBrowsePageUrl() {
var path = (window.location.pathname || '').toLowerCase(); var path = (window.location.pathname || '').toLowerCase();
if ( if (
path.indexOf('/videos/watch') === 0 || path.indexOf('/videos/watch') === 0 ||
@@ -3165,12 +3175,9 @@ try {
path.indexOf('/my-library') === 0 || path.indexOf('/my-library') === 0 ||
path.indexOf('/settings') === 0 path.indexOf('/settings') === 0
) { ) {
var oldBar = document.getElementById('yaktube-category-chips-bar'); return false;
if (oldBar) oldBar.remove();
return;
} }
return (
var isBrowsePage =
path === '/' || path === '/' ||
path === '' || path === '' ||
path === '/videos/overview' || path === '/videos/overview' ||
@@ -3180,9 +3187,12 @@ try {
path.indexOf('/search') === 0 || path.indexOf('/search') === 0 ||
path.indexOf('/videos/trending') === 0 || path.indexOf('/videos/trending') === 0 ||
path.indexOf('/videos/recently-added') === 0 || path.indexOf('/videos/recently-added') === 0 ||
path.indexOf('/videos/local') === 0; path.indexOf('/videos/local') === 0
);
}
if (!isBrowsePage) { function injectCategoryChipsBar() {
if (!isBrowsePageUrl()) {
var exBar = document.getElementById('yaktube-category-chips-bar'); var exBar = document.getElementById('yaktube-category-chips-bar');
if (exBar) exBar.remove(); if (exBar) exBar.remove();
return; return;
@@ -3385,36 +3395,41 @@ try {
} }
function injectSkipToCategoriesLink() { function injectSkipToCategoriesLink() {
if (document.getElementById('yaktube-skip-to-categories')) return; var skipLink = document.getElementById('yaktube-skip-to-categories');
// Only show top skip-link on browse / overview pages where category bar actually exists
if (!isBrowsePageUrl()) {
if (skipLink) skipLink.remove();
return;
}
var skipContent = document.querySelector('.skip-to-content, a[href*="content"]'); var skipContent = document.querySelector('.skip-to-content, a[href*="content"]');
var toggleBtn = document.querySelector('.toggle-menu, button[title*="Yanal"], button[aria-label*="Yanal"]'); if (!skipContent) return;
var skipLink = document.createElement('a'); if (!skipLink) {
skipLink.id = 'yaktube-skip-to-categories'; skipLink = document.createElement('a');
skipLink.href = '#yaktube-category-chips-bar'; skipLink.id = 'yaktube-skip-to-categories';
skipLink.className = 'visually-hidden-focusable skip-to-content yaktube-skip-categories'; skipLink.href = '#yaktube-category-chips-bar';
skipLink.setAttribute('aria-label', 'Kategorilere atla'); skipLink.className = 'visually-hidden-focusable skip-to-content yaktube-skip-categories';
skipLink.textContent = 'Kategorilere atla'; skipLink.setAttribute('aria-label', 'Kategorilere atla');
skipLink.textContent = 'Kategorilere atla';
skipLink.addEventListener('click', function (e) { skipLink.addEventListener('click', function (e) {
e.preventDefault();
jumpToCategories();
});
skipLink.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault(); e.preventDefault();
jumpToCategories(); jumpToCategories();
} });
});
if (skipContent && skipContent.parentElement) { skipLink.addEventListener('keydown', function (e) {
skipContent.parentElement.insertBefore(skipLink, skipContent.nextSibling); if (e.key === 'Enter' || e.key === ' ') {
} else if (toggleBtn && toggleBtn.parentElement) { e.preventDefault();
toggleBtn.parentElement.insertBefore(skipLink, toggleBtn); jumpToCategories();
} else { }
document.body.prepend(skipLink); });
}
// GUARANTEE: skipLink MUST ALWAYS be placed IMMEDIATELY AFTER skipContent ("Ana içeriğe atla")
if (skipContent.nextElementSibling !== skipLink) {
skipContent.insertAdjacentElement('afterend', skipLink);
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.6.4", "version": "1.6.5",
"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",