Compare commits

...
1 Commits
3 changed files with 91 additions and 58 deletions
+84 -44
View File
@@ -6148,10 +6148,24 @@ try {
} }
window.__yaktube_play_next_smart__ = playFirstSmartRecommendation; 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() { function disableNativePeerTubeAutoplaySwitch() {
try { try {
if (localStorage.getItem('auto-play-video') !== 'false') {
localStorage.setItem('auto-play-video', 'false'); localStorage.setItem('auto-play-video', 'false');
}
if (sessionStorage.getItem('auto-play-video') !== 'false') {
sessionStorage.setItem('auto-play-video', 'false'); sessionStorage.setItem('auto-play-video', 'false');
}
} catch (e) {} } catch (e) {}
// Uncheck any native PeerTube Fediverse autoplay checkbox so Angular's internal autoPlayNextVideo stays false // Uncheck any native PeerTube Fediverse autoplay checkbox so Angular's internal autoPlayNextVideo stays false
@@ -6171,10 +6185,7 @@ try {
var nativeAutoplayHeaders = document.querySelectorAll( 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"]' '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) { nativeAutoplayHeaders.forEach(setHiddenImportantIfChanged);
el.style.setProperty('display', 'none', 'important');
el.setAttribute('aria-hidden', 'true');
});
} }
function syncPlayerNextButtonAndAutoplayUI() { function syncPlayerNextButtonAndAutoplayUI() {
@@ -6183,9 +6194,13 @@ try {
var barAutoBtn = document.getElementById('yaktube-bar-autoplay-btn'); var barAutoBtn = document.getElementById('yaktube-bar-autoplay-btn');
if (barAutoBtn) { if (barAutoBtn) {
barAutoBtn.setAttribute('aria-checked', autoOn ? 'true' : 'false'); var nextChecked = autoOn ? 'true' : 'false';
barAutoBtn.setAttribute('aria-label', 'Akıllı Otomatik Oynatma: ' + (autoOn ? 'Açık' : 'Kapalı')); var nextAria = 'Akıllı Otomatik Oynatma: ' + (autoOn ? 'Açık' : 'Kapalı');
barAutoBtn.textContent = autoOn ? '🔁 Oto-Oynat: Açık' : '🔁 Oto-Oynat: 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'); var barNextBtn = document.getElementById('yaktube-bar-next-btn');
@@ -6194,29 +6209,26 @@ try {
firstRec && firstRec.title firstRec && firstRec.title
? 'Sıradaki İlk Öneri: ' + firstRec.title + ' (Shift+N)' ? 'Sıradaki İlk Öneri: ' + firstRec.title + ' (Shift+N)'
: 'Sıradaki İlk Önerilen Videoyu Oynat (Shift+N)'; : 'Sıradaki İlk Önerilen Videoyu Oynat (Shift+N)';
barNextBtn.setAttribute('aria-label', barNextLabel); if (barNextBtn.getAttribute('aria-label') !== barNextLabel) barNextBtn.setAttribute('aria-label', barNextLabel);
barNextBtn.setAttribute('title', barNextLabel); if (barNextBtn.getAttribute('title') !== barNextLabel) barNextBtn.setAttribute('title', barNextLabel);
} }
if (!isPlaylistWatch()) { if (!isPlaylistWatch()) {
// Hide PeerTube's native Fediverse upnext overlay inside Video.js so YakTube Smart Autoplay handles it // Hide PeerTube's native Fediverse upnext overlay inside Video.js so YakTube Smart Autoplay handles it
var nativeUpNext = document.querySelectorAll('.vjs-upnext-content'); var nativeUpNext = document.querySelectorAll('.vjs-upnext-content');
nativeUpNext.forEach(function (el) { nativeUpNext.forEach(setHiddenImportantIfChanged);
el.style.setProperty('display', 'none', 'important');
el.setAttribute('aria-hidden', 'true');
});
var nextBtns = document.querySelectorAll('.vjs-next-video, .vjs-next-video-control, .vjs-next-control'); var nextBtns = document.querySelectorAll('.vjs-next-video, .vjs-next-video-control, .vjs-next-control');
nextBtns.forEach(function (btn) { nextBtns.forEach(function (btn) {
if (firstRec) { if (firstRec) {
btn.classList.remove('vjs-disabled'); if (btn.classList.contains('vjs-disabled')) btn.classList.remove('vjs-disabled');
btn.classList.remove('vjs-hidden'); if (btn.classList.contains('vjs-hidden')) btn.classList.remove('vjs-hidden');
btn.removeAttribute('disabled'); if (btn.hasAttribute('disabled')) btn.removeAttribute('disabled');
var lbl = 'Sonraki Video (İlk Öneri): ' + (firstRec.title || '') + ' (Shift+N)'; var lbl = 'Sonraki Video (İlk Öneri): ' + (firstRec.title || '') + ' (Shift+N)';
btn.setAttribute('aria-label', lbl); if (btn.getAttribute('aria-label') !== lbl) btn.setAttribute('aria-label', lbl);
btn.setAttribute('title', lbl); if (btn.getAttribute('title') !== lbl) btn.setAttribute('title', lbl);
var ctrlTxt = btn.querySelector('.vjs-control-text'); 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 &&
(child.classList.contains('other-videos-header') || child.classList.contains('autoplay-line')) (child.classList.contains('other-videos-header') || child.classList.contains('autoplay-line'))
) { ) {
child.style.setProperty('display', 'none', 'important'); setHiddenImportantIfChanged(child);
child.setAttribute('aria-hidden', 'true');
return; return;
} }
if (child.tagName && child.tagName.toLowerCase() === 'my-input-switch') { if (child.tagName && child.tagName.toLowerCase() === 'my-input-switch') {
child.style.setProperty('display', 'none', 'important'); setHiddenImportantIfChanged(child);
child.setAttribute('aria-hidden', 'true');
return; return;
} }
if (shouldShowNativeList) { if (shouldShowNativeList) {
child.style.removeProperty('display'); if (child.style.getPropertyValue('display')) child.style.removeProperty('display');
child.removeAttribute('aria-hidden'); if (child.hasAttribute('aria-hidden')) child.removeAttribute('aria-hidden');
} else { } else {
child.style.setProperty('display', 'none', 'important'); setHiddenImportantIfChanged(child);
child.setAttribute('aria-hidden', 'true');
} }
}); });
}); });
disableNativePeerTubeAutoplaySwitch();
} }
function renderRelatedCards(container, results, query) { function renderRelatedCards(container, results, query) {
@@ -6402,9 +6409,11 @@ try {
' kanalı, Süre: ' + ' kanalı, Süre: ' +
(item.durationFormatted || ''); (item.durationFormatted || '');
cardsHtml += cardsHtml +=
'<div class="yaktube-card" role="article" tabindex="0" style="margin-bottom:10px;' + '<div class="yaktube-card" data-yt-id="' +
(isFirstRec ? ' border: 1.5px solid rgba(255,143,55,0.65);' : '') + escapeHtml(item.id || '') +
'" aria-label="' + '" role="article" tabindex="0"' +
(isFirstRec ? ' style="border: 1.5px solid rgba(255,143,55,0.65);"' : '') +
' aria-label="' +
cardLabel.replace(/"/g, '&quot;') + cardLabel.replace(/"/g, '&quot;') +
'">' + '">' +
'<div class="yaktube-thumb-wrap">' + '<div class="yaktube-thumb-wrap">' +
@@ -6491,7 +6500,9 @@ try {
'" İçeriğine Özel Öneriler (' + '" İçeriğine Özel Öneriler (' +
headerCountText + headerCountText +
')</h3>' + ')</h3>' +
'<span id="yaktube-smart-prefetch-status-slot">' +
prefetchStatusHtml + prefetchStatusHtml +
'</span>' +
'</div>' + '</div>' +
'<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">' + '<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">' +
'<button id="yaktube-related-play-first-btn" class="yaktube-shortcuts-btn" style="background:rgba(255,143,55,0.16); border-color:#ff8f37; color:#fff; font-weight:700;" aria-label="Sıradaki ilk önerilen videoyu oynat (Shift+N)" title="Sıradaki ilk önerilen videoyu oynat (Shift+N)">' + '<button id="yaktube-related-play-first-btn" class="yaktube-shortcuts-btn" style="background:rgba(255,143,55,0.16); border-color:#ff8f37; color:#fff; font-weight:700;" aria-label="Sıradaki ilk önerilen videoyu oynat (Shift+N)" title="Sıradaki ilk önerilen videoyu oynat (Shift+N)">' +
@@ -6594,6 +6605,42 @@ try {
}); });
} }
function updatePrefetchBadgeInPlace(status) {
var slot = document.getElementById('yaktube-smart-prefetch-status-slot');
if (!slot) return;
if (status === 'preparing') {
slot.innerHTML =
'<span id="yaktube-smart-prefetch-status" style="font-size:11px; color:#38bdf8; background:rgba(56,189,248,0.12); border:1px solid rgba(56,189,248,0.3); padding:3px 9px; border-radius:20px; font-weight:600;">⚡ Sıradaki öneri arka planda hazırlanıyor...</span>';
} else if (status === 'ready') {
slot.innerHTML =
'<span id="yaktube-smart-prefetch-status" style="font-size:11px; color:#10b981; background:rgba(16,185,129,0.14); border:1px solid rgba(16,185,129,0.35); padding:3px 9px; border-radius:20px; font-weight:700;">✅ Sıradaki öneri kesintisiz izlemeye hazır!</span>';
}
}
function upgradePrefetchedCardInPlace(candidate, watchUrl, videoUuid) {
if (!candidate || !candidate.id || !watchUrl) return;
var card = document.querySelector(
'#yaktube-hybrid-related-container .yaktube-card[data-yt-id="' + candidate.id + '"]'
);
if (!card) return;
var btn = card.querySelector('.yaktube-related-import');
if (btn && btn.parentNode) {
var link = document.createElement('a');
link.href = watchUrl;
link.className = 'yaktube-play-btn yaktube-related-play-link';
link.setAttribute('data-uuid', videoUuid || '');
link.setAttribute('data-yt-id', candidate.id || '');
link.setAttribute('data-title', candidate.title || '');
link.setAttribute('data-channel', candidate.channel || '');
link.style.cssText = 'font-size:11px; padding:6px 10px;';
link.textContent = '▶️ Hemen İzle';
link.addEventListener('click', function () {
currentActiveVideoKey = null;
});
btn.parentNode.replaceChild(link, btn);
}
}
function triggerSilentBackgroundPrefetch(candidate, videoKey) { function triggerSilentBackgroundPrefetch(candidate, videoKey) {
if (!candidate || !candidate.url || !videoKey) return; if (!candidate || !candidate.url || !videoKey) return;
if (smartPrefetchState.videoKey === videoKey && smartPrefetchState.status !== 'idle') return; if (smartPrefetchState.videoKey === videoKey && smartPrefetchState.status !== 'idle') return;
@@ -6627,10 +6674,7 @@ try {
smartPrefetchState.readyUrl = null; smartPrefetchState.readyUrl = null;
smartPrefetchState.readyTitle = candidate.title; smartPrefetchState.readyTitle = candidate.title;
var relContainer = document.getElementById('yaktube-hybrid-related-container'); updatePrefetchBadgeInPlace('preparing');
if (relContainer && cachedRelatedResults.length > 0) {
renderRelatedCards(relContainer, cachedRelatedResults, cachedRelatedQuery);
}
var headers = { 'Content-Type': 'application/json' }; var headers = { 'Content-Type': 'application/json' };
try { try {
@@ -6673,10 +6717,8 @@ try {
}; };
} }
}); });
var relC = document.getElementById('yaktube-hybrid-related-container'); updatePrefetchBadgeInPlace('ready');
if (relC && cachedRelatedResults.length > 0) { upgradePrefetchedCardInPlace(candidate, immediateWatchUrl, videoUuid);
renderRelatedCards(relC, cachedRelatedResults, cachedRelatedQuery);
}
return; return;
} }
@@ -6713,10 +6755,8 @@ try {
} }
}); });
var c = document.getElementById('yaktube-hybrid-related-container'); updatePrefetchBadgeInPlace('ready');
if (c && cachedRelatedResults.length > 0) { upgradePrefetchedCardInPlace(candidate, watchUrl, sData.uuid || videoUuid);
renderRelatedCards(c, cachedRelatedResults, cachedRelatedQuery);
}
} else if (sData && sData.isFailed) { } else if (sData && sData.isFailed) {
clearInterval(smartPrefetchState.pollTimer); clearInterval(smartPrefetchState.pollTimer);
smartPrefetchState.pollTimer = null; smartPrefetchState.pollTimer = null;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.7.17", "version": "1.7.18",
"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",
+4 -11
View File
@@ -75,13 +75,13 @@ a[href*='joinpeertube'] {
.yaktube-ondemand-section { .yaktube-ondemand-section {
margin: 24px 0; margin: 24px 0;
padding: 20px; padding: 20px;
background: rgba(22, 22, 30, 0.92); background: rgba(18, 20, 28, 0.96);
border: 1px solid rgba(255, 143, 55, 0.35); border: 1px solid rgba(255, 143, 55, 0.35);
border-radius: 16px; border-radius: 16px;
backdrop-filter: blur(10px);
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
color: #fff; color: #fff;
font-family: inherit; font-family: inherit;
overflow-anchor: none;
} }
.yaktube-header { .yaktube-header {
@@ -153,16 +153,14 @@ a[href*='joinpeertube'] {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
transition: transition:
transform 0.2s ease,
border-color 0.2s ease, border-color 0.2s ease,
box-shadow 0.2s ease; box-shadow 0.2s ease;
} }
.yaktube-card:hover, .yaktube-card:hover,
.yaktube-card:focus-within { .yaktube-card:focus-within {
transform: translateY(-4px); border-color: rgba(255, 143, 55, 0.65);
border-color: rgba(255, 143, 55, 0.6); box-shadow: 0 8px 20px rgba(255, 143, 55, 0.18);
box-shadow: 0 10px 22px rgba(255, 143, 55, 0.18);
} }
.yaktube-thumb-wrap { .yaktube-thumb-wrap {
@@ -180,11 +178,6 @@ a[href*='joinpeertube'] {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
transition: transform 0.3s ease;
}
.yaktube-card:hover .yaktube-thumb-img {
transform: scale(1.05);
} }
.yaktube-duration-badge { .yaktube-duration-badge {