From 333383442fb6b00633ab49ee99e0b07b22d0b532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Yak=C4=B1=C5=9Ft=C4=B1r?= Date: Sun, 18 Oct 2026 22:58:25 +0300 Subject: [PATCH] feat(a11y): add skip-to-categories link at page top and sidebar shortcut (v1.6.4) --- client.js | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- style.css | 48 +++++++++++++++++++++++- 3 files changed, 151 insertions(+), 2 deletions(-) diff --git a/client.js b/client.js index adbc374..3fc78d1 100644 --- a/client.js +++ b/client.js @@ -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 = + ' Kategorilere atla'; + + 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 setTimeout(function () { fetchGuestImportLimit(); @@ -5631,6 +5726,14 @@ try { injectCategoryChipsBar(); } catch (e) {} + try { + injectSkipToCategoriesLink(); + } catch (e) {} + + try { + injectSidebarCategoriesLink(); + } catch (e) {} + try { checkAndInjectRelatedVideos(Boolean(isNav)); } catch (e) {} diff --git a/package.json b/package.json index 037e29d..0600f93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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", "main": "main.js", "library": "./main.js", diff --git a/style.css b/style.css index bc09489..82dda68 100644 --- a/style.css +++ b/style.css @@ -1633,7 +1633,7 @@ my-date-toggle .date-toggle:focus-visible { } .yaktube-category-chip.active, -.yaktube-category-chip[aria-selected="true"] { +.yaktube-category-chip[aria-selected='true'] { background: #ff8f37 !important; color: #000000 !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; +}