diff --git a/client.js b/client.js index 672244f..e6c9ad2 100644 --- a/client.js +++ b/client.js @@ -6148,10 +6148,24 @@ try { } window.__yaktube_play_next_smart__ = playFirstSmartRecommendation; + function setHiddenImportantIfChanged(el) { + if (!el) return; + if (el.style.getPropertyValue('display') !== 'none' || el.style.getPropertyPriority('display') !== 'important') { + el.style.setProperty('display', 'none', 'important'); + } + if (el.getAttribute('aria-hidden') !== 'true') { + el.setAttribute('aria-hidden', 'true'); + } + } + function disableNativePeerTubeAutoplaySwitch() { try { - localStorage.setItem('auto-play-video', 'false'); - sessionStorage.setItem('auto-play-video', 'false'); + if (localStorage.getItem('auto-play-video') !== 'false') { + localStorage.setItem('auto-play-video', 'false'); + } + if (sessionStorage.getItem('auto-play-video') !== 'false') { + sessionStorage.setItem('auto-play-video', 'false'); + } } catch (e) {} // Uncheck any native PeerTube Fediverse autoplay checkbox so Angular's internal autoPlayNextVideo stays false @@ -6171,10 +6185,7 @@ try { var nativeAutoplayHeaders = document.querySelectorAll( 'my-recommended-videos .other-videos-header, .other-videos .other-videos-header, my-recommended-videos my-input-switch, .other-videos my-input-switch, my-recommended-videos .autoplay-line, .other-videos .autoplay-line, #auto-play-video, label[for="auto-play-video"]' ); - nativeAutoplayHeaders.forEach(function (el) { - el.style.setProperty('display', 'none', 'important'); - el.setAttribute('aria-hidden', 'true'); - }); + nativeAutoplayHeaders.forEach(setHiddenImportantIfChanged); } function syncPlayerNextButtonAndAutoplayUI() { @@ -6183,9 +6194,13 @@ try { var barAutoBtn = document.getElementById('yaktube-bar-autoplay-btn'); if (barAutoBtn) { - barAutoBtn.setAttribute('aria-checked', autoOn ? 'true' : 'false'); - barAutoBtn.setAttribute('aria-label', 'Akıllı Otomatik Oynatma: ' + (autoOn ? 'Açık' : 'Kapalı')); - barAutoBtn.textContent = autoOn ? '🔁 Oto-Oynat: Açık' : '🔁 Oto-Oynat: Kapalı'; + var nextChecked = autoOn ? 'true' : 'false'; + var nextAria = 'Akıllı Otomatik Oynatma: ' + (autoOn ? 'Açık' : 'Kapalı'); + var nextTxt = autoOn ? '🔁 Oto-Oynat: Açık' : '🔁 Oto-Oynat: Kapalı'; + if (barAutoBtn.getAttribute('aria-checked') !== nextChecked) + barAutoBtn.setAttribute('aria-checked', nextChecked); + if (barAutoBtn.getAttribute('aria-label') !== nextAria) barAutoBtn.setAttribute('aria-label', nextAria); + if (barAutoBtn.textContent !== nextTxt) barAutoBtn.textContent = nextTxt; } var barNextBtn = document.getElementById('yaktube-bar-next-btn'); @@ -6194,29 +6209,26 @@ try { firstRec && firstRec.title ? 'Sıradaki İlk Öneri: ' + firstRec.title + ' (Shift+N)' : 'Sıradaki İlk Önerilen Videoyu Oynat (Shift+N)'; - barNextBtn.setAttribute('aria-label', barNextLabel); - barNextBtn.setAttribute('title', barNextLabel); + if (barNextBtn.getAttribute('aria-label') !== barNextLabel) barNextBtn.setAttribute('aria-label', barNextLabel); + if (barNextBtn.getAttribute('title') !== barNextLabel) barNextBtn.setAttribute('title', barNextLabel); } if (!isPlaylistWatch()) { // Hide PeerTube's native Fediverse upnext overlay inside Video.js so YakTube Smart Autoplay handles it var nativeUpNext = document.querySelectorAll('.vjs-upnext-content'); - nativeUpNext.forEach(function (el) { - el.style.setProperty('display', 'none', 'important'); - el.setAttribute('aria-hidden', 'true'); - }); + nativeUpNext.forEach(setHiddenImportantIfChanged); var nextBtns = document.querySelectorAll('.vjs-next-video, .vjs-next-video-control, .vjs-next-control'); nextBtns.forEach(function (btn) { if (firstRec) { - btn.classList.remove('vjs-disabled'); - btn.classList.remove('vjs-hidden'); - btn.removeAttribute('disabled'); + if (btn.classList.contains('vjs-disabled')) btn.classList.remove('vjs-disabled'); + if (btn.classList.contains('vjs-hidden')) btn.classList.remove('vjs-hidden'); + if (btn.hasAttribute('disabled')) btn.removeAttribute('disabled'); var lbl = 'Sonraki Video (İlk Öneri): ' + (firstRec.title || '') + ' (Shift+N)'; - btn.setAttribute('aria-label', lbl); - btn.setAttribute('title', lbl); + if (btn.getAttribute('aria-label') !== lbl) btn.setAttribute('aria-label', lbl); + if (btn.getAttribute('title') !== lbl) btn.setAttribute('title', lbl); var ctrlTxt = btn.querySelector('.vjs-control-text'); - if (ctrlTxt) ctrlTxt.textContent = lbl; + if (ctrlTxt && ctrlTxt.textContent !== lbl) ctrlTxt.textContent = lbl; } }); } @@ -6277,26 +6289,21 @@ try { child.classList && (child.classList.contains('other-videos-header') || child.classList.contains('autoplay-line')) ) { - child.style.setProperty('display', 'none', 'important'); - child.setAttribute('aria-hidden', 'true'); + setHiddenImportantIfChanged(child); return; } if (child.tagName && child.tagName.toLowerCase() === 'my-input-switch') { - child.style.setProperty('display', 'none', 'important'); - child.setAttribute('aria-hidden', 'true'); + setHiddenImportantIfChanged(child); return; } if (shouldShowNativeList) { - child.style.removeProperty('display'); - child.removeAttribute('aria-hidden'); + if (child.style.getPropertyValue('display')) child.style.removeProperty('display'); + if (child.hasAttribute('aria-hidden')) child.removeAttribute('aria-hidden'); } else { - child.style.setProperty('display', 'none', 'important'); - child.setAttribute('aria-hidden', 'true'); + setHiddenImportantIfChanged(child); } }); }); - - disableNativePeerTubeAutoplaySwitch(); } function renderRelatedCards(container, results, query) { @@ -6402,9 +6409,11 @@ try { ' kanalı, Süre: ' + (item.durationFormatted || ''); cardsHtml += - '