Compare commits

..
6 Commits
3 changed files with 3033 additions and 2925 deletions
+134 -52
View File
@@ -1,4 +1,5 @@
(function () { try {
(function () {
if (window.__YAKTUBE_ENGINE_LOADED__) return; if (window.__YAKTUBE_ENGINE_LOADED__) return;
window.__YAKTUBE_ENGINE_LOADED__ = true; window.__YAKTUBE_ENGINE_LOADED__ = true;
console.log('[YakTube] YakNet SSO, Custom Branding, A11y & On-Demand Engine Active'); console.log('[YakTube] YakNet SSO, Custom Branding, A11y & On-Demand Engine Active');
@@ -49,6 +50,52 @@
}, 50); }, 50);
} }
// Load official YakNet Web Component definition
if (
typeof customElements !== 'undefined' &&
!customElements.get('yaknet-account') &&
!document.getElementById('yaknet-account-script')
) {
var s = document.createElement('script');
s.id = 'yaknet-account-script';
s.src = 'https://auth.yakhub.com.tr/js/yaknet-account.js';
s.async = true;
document.head.appendChild(s);
}
// Silent background SSO Probe Engine
function initSilentSSOProbe() {
var token = localStorage.getItem('access_token');
var isManualLogout = sessionStorage.getItem('yaknet_manual_logout');
if (
token ||
isManualLogout ||
window.location.search.includes('local=true') ||
window.location.search.includes('externalAuthError') ||
window.location.pathname.includes('/login')
) {
return;
}
var iframeId = 'yaknet-sso-iframe-instance';
if (!document.getElementById(iframeId)) {
var iframe = document.createElement('iframe');
iframe.id = iframeId;
iframe.src = 'https://auth.yakhub.com.tr/sdk/sso-frame';
iframe.title = 'YakNet Oturum Kontrolü';
iframe.setAttribute('aria-hidden', 'true');
iframe.tabIndex = -1;
iframe.style.cssText =
'display:none!important;width:0!important;height:0!important;border:0!important;position:absolute!important;pointer-events:none!important;';
document.body.appendChild(iframe);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initSilentSSOProbe);
} else {
initSilentSSOProbe();
}
function triggerYakNetOAuth() { function triggerYakNetOAuth() {
sessionStorage.removeItem('yaknet_manual_logout'); sessionStorage.removeItem('yaknet_manual_logout');
var callbackUrl = 'https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback'; var callbackUrl = 'https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback';
@@ -287,7 +334,7 @@
var liveWidget = headerRight.querySelector('#yaknet-header-account-widget'); var liveWidget = headerRight.querySelector('#yaknet-header-account-widget');
if (isAuth) { if (isAuth) {
// Logged In: Show YakNet Profile Menu, Hide default login link // 1. AUTHENTICATED: Hide native login link, Show YakNet Account Profile Menu
if (defaultLoginLink) { if (defaultLoginLink) {
defaultLoginLink.style.display = 'none'; defaultLoginLink.style.display = 'none';
defaultLoginLink.setAttribute('aria-hidden', 'true'); defaultLoginLink.setAttribute('aria-hidden', 'true');
@@ -332,6 +379,16 @@
} else { } else {
var el = liveWidget.querySelector('yaknet-account'); var el = liveWidget.querySelector('yaknet-account');
if (el) { if (el) {
if (el.getAttribute('authenticated') !== 'true' || el.getAttribute('user-name') !== displayName) {
el.setAttribute('authenticated', 'true');
el.setAttribute('user-name', displayName);
el.setAttribute('user-email', emailStr);
if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes();
el.render();
}
}
if (el.shadowRoot) { if (el.shadowRoot) {
var shadowLogoutBtn = var shadowLogoutBtn =
el.shadowRoot.getElementById('logoutBtn') || el.shadowRoot.getElementById('logoutBtn') ||
@@ -350,23 +407,16 @@
); );
} }
} }
if (el.getAttribute('authenticated') !== 'true' || el.getAttribute('user-name') !== displayName) {
el.setAttribute('authenticated', 'true');
el.setAttribute('user-name', displayName);
el.setAttribute('user-email', emailStr);
if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes();
el.render();
}
}
} }
} }
} else { } else {
// Not Logged In: Remove YakNet widget to eliminate duplicate button, keep PeerTube native login button clean // 2. GUEST / NOT LOGGED IN:
// A. Physically remove any <yaknet-account> widget from DOM to guarantee zero shadow DOM duplicate buttons
if (liveWidget) { if (liveWidget) {
liveWidget.remove(); liveWidget.remove();
} }
// B. Ensure PeerTube's native login link is the ONLY single accessible login element
if (defaultLoginLink) { if (defaultLoginLink) {
defaultLoginLink.style.display = ''; defaultLoginLink.style.display = '';
defaultLoginLink.removeAttribute('aria-hidden'); defaultLoginLink.removeAttribute('aria-hidden');
@@ -375,7 +425,7 @@
defaultLoginLink.tagName.toLowerCase() === 'a' ? defaultLoginLink : defaultLoginLink.querySelector('a'); defaultLoginLink.tagName.toLowerCase() === 'a' ? defaultLoginLink : defaultLoginLink.querySelector('a');
if (loginAnchor) { if (loginAnchor) {
loginAnchor.setAttribute('aria-label', 'YakNet ile Giriş Yap'); loginAnchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
loginAnchor.setAttribute('title', 'YakNet Hesabınız ile Giriş Yapın'); loginAnchor.setAttribute('title', 'YakNet ile Giriş Yap');
var spanText = loginAnchor.querySelector('span'); var spanText = loginAnchor.querySelector('span');
if (spanText) { if (spanText) {
spanText.textContent = 'YakNet ile Giriş Yap'; spanText.textContent = 'YakNet ile Giriş Yap';
@@ -443,7 +493,9 @@
if (containerToHide && !isLocalLogin) { if (containerToHide && !isLocalLogin) {
var subElements = Array.from(loginCard.children).filter(function (el) { var subElements = Array.from(loginCard.children).filter(function (el) {
return ( return (
el.id !== 'yaknet-login-section' && !el.classList.contains('title') && !el.classList.contains('page-title') el.id !== 'yaknet-login-section' &&
!el.classList.contains('title') &&
!el.classList.contains('page-title')
); );
}); });
@@ -669,7 +721,9 @@
if (!alt || alt.trim() === '') { if (!alt || alt.trim() === '') {
var card = img.closest('.video-miniature, .video-card, .yaktube-card, [class*="miniature"]'); var card = img.closest('.video-miniature, .video-card, .yaktube-card, [class*="miniature"]');
if (card) { if (card) {
var titleEl = card.querySelector('.video-miniature-name, .video-name, .yaktube-video-name, h3, h4, a[title]'); var titleEl = card.querySelector(
'.video-miniature-name, .video-name, .yaktube-video-name, h3, h4, a[title]'
);
var titleText = titleEl ? (titleEl.textContent || titleEl.getAttribute('title') || '').trim() : ''; var titleText = titleEl ? (titleEl.textContent || titleEl.getAttribute('title') || '').trim() : '';
if (titleText) { if (titleText) {
img.setAttribute('alt', titleText + ' video kapağı'); img.setAttribute('alt', titleText + ' video kapağı');
@@ -1499,7 +1553,10 @@
if (sData.isImporting) { if (sData.isImporting) {
showModal('[1/2] 📥 Video İndiriliyor...', 'Video sunucuya indiriliyor (' + attempts * 2 + ' sn)...'); showModal('[1/2] 📥 Video İndiriliyor...', 'Video sunucuya indiriliyor (' + attempts * 2 + ' sn)...');
} else if (sData.isTranscoding) { } else if (sData.isTranscoding) {
showModal('[2/2] ⚙️ Oynatıcı Hazırlanıyor...', 'Video işleniyor ve yüksek kalite akış hazırlanıyor...'); showModal(
'[2/2] ⚙️ Oynatıcı Hazırlanıyor...',
'Video işleniyor ve yüksek kalite akış hazırlanıyor...'
);
} }
if (sData.isPublished || (sData.hasFiles && attempts >= 8)) { if (sData.isPublished || (sData.hasFiles && attempts >= 8)) {
@@ -2222,7 +2279,10 @@
var nativeInputs = searchContainer.querySelectorAll('input, button'); var nativeInputs = searchContainer.querySelectorAll('input, button');
nativeInputs.forEach(function (el) { nativeInputs.forEach(function (el) {
if (!el.classList.contains('yaktube-search-trigger-pill') && !el.classList.contains('yaktube-voice-search-btn')) { if (
!el.classList.contains('yaktube-search-trigger-pill') &&
!el.classList.contains('yaktube-voice-search-btn')
) {
el.style.display = 'none'; el.style.display = 'none';
el.setAttribute('tabindex', '-1'); el.setAttribute('tabindex', '-1');
el.setAttribute('aria-hidden', 'true'); el.setAttribute('aria-hidden', 'true');
@@ -2488,7 +2548,8 @@
} }
function checkAndInjectRelatedVideos(forceReload) { function checkAndInjectRelatedVideos(forceReload) {
var isWatchPage = window.location.pathname.includes('/videos/watch/') || window.location.pathname.startsWith('/w/'); var isWatchPage =
window.location.pathname.includes('/videos/watch/') || window.location.pathname.startsWith('/w/');
if (!isWatchPage) { if (!isWatchPage) {
var existing = document.getElementById('yaktube-hybrid-related-container'); var existing = document.getElementById('yaktube-hybrid-related-container');
if (existing) existing.remove(); if (existing) existing.remove();
@@ -2766,7 +2827,10 @@
card.className = 'yaktube-comment-item'; card.className = 'yaktube-comment-item';
card.setAttribute('role', 'article'); card.setAttribute('role', 'article');
card.setAttribute('tabindex', '0'); card.setAttribute('tabindex', '0');
card.setAttribute('aria-label', c.author + ' isimli kullan\u0131c\u0131n\u0131n yorumu: ' + c.content); card.setAttribute(
'aria-label',
c.author + ' isimli kullan\u0131c\u0131n\u0131n yorumu: ' + c.content
);
card.style.cssText = card.style.cssText =
'background: #1e293b; padding: 14px 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); display: flex; gap: 12px; align-items: flex-start;'; 'background: #1e293b; padding: 14px 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); display: flex; gap: 12px; align-items: flex-start;';
@@ -2842,9 +2906,11 @@
// 6. PWA Mobile App Install Engine & Standalone Detection // 6. PWA Mobile App Install Engine & Standalone Detection
var isInsideYakTubeApp = var isInsideYakTubeApp =
navigator.userAgent.indexOf('YakTubeMobileApp') !== -1 || (navigator.userAgent && navigator.userAgent.indexOf('YakTubeMobileApp') !== -1) ||
window.matchMedia('(display-mode: standalone)').matches || (typeof window.matchMedia === 'function' &&
window.navigator.standalone === true; window.matchMedia('(display-mode: standalone)') &&
window.matchMedia('(display-mode: standalone)').matches) ||
(window.navigator && window.navigator.standalone === true);
var isMobileDevice = /Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent); var isMobileDevice = /Android|iPhone|iPad|iPod|Mobile|Tablet/i.test(navigator.userAgent);
@@ -2996,14 +3062,14 @@
checkAndInjectWatchPageComments(); checkAndInjectWatchPageComments();
}); });
checkAndInjectWatchPageComments(); checkAndInjectWatchPageComments();
})(); })();
// 5. Background Play (Screen-Off / Minimize) & MediaSession Lock-Screen Controls // 5. Background Play (Screen-Off / Minimize) & MediaSession Lock-Screen Controls
(function initBackgroundPlaybackEngine() { (function initBackgroundPlaybackEngine() {
var videoState = { var videoState = {
hasPlayed: false, hasPlayed: false,
pausedByUser: false, explicitlyPausedByClick: false,
pausedAt: null lastPlayTime: 0
}; };
function attachVideoListeners(video) { function attachVideoListeners(video) {
@@ -3012,21 +3078,14 @@
video.addEventListener('play', function () { video.addEventListener('play', function () {
videoState.hasPlayed = true; videoState.hasPlayed = true;
videoState.pausedByUser = false; videoState.explicitlyPausedByClick = false;
videoState.lastPlayTime = Date.now();
updateMediaSessionMetadata(video); updateMediaSessionMetadata(video);
}); });
video.addEventListener('pause', function () {
videoState.pausedAt = Date.now();
// If document is visible when paused, it was paused manually by the user
if (!document.hidden) {
videoState.pausedByUser = true;
}
});
video.addEventListener('ended', function () { video.addEventListener('ended', function () {
videoState.hasPlayed = false; videoState.hasPlayed = false;
videoState.pausedByUser = true; videoState.explicitlyPausedByClick = true;
}); });
video.addEventListener('timeupdate', function () { video.addEventListener('timeupdate', function () {
@@ -3034,30 +3093,50 @@
}); });
} }
function handleVisibilityChange() { // Hook manual play/pause buttons
if (!document.hidden) return; // Screen is active document.addEventListener(
'click',
function (e) {
var target = e.target;
if (!target) return;
var btn = target.closest(
'.vjs-play-control, button[title*="Duraklat"], button[aria-label*="Duraklat"], #yaktube-bar-play-btn'
);
if (btn) {
var video = getVideoElement();
if (video && !video.paused) {
videoState.explicitlyPausedByClick = true;
}
}
},
true
);
function handleVisibilityChange() {
var video = getVideoElement(); var video = getVideoElement();
if (!video) return; if (!video) return;
// If user hasn't played or deliberately paused, do not auto-resume // When screen turns off / tab is hidden:
if (!videoState.hasPlayed || videoState.pausedByUser) return; if (document.hidden || document.webkitHidden) {
if (videoState.hasPlayed && !videoState.explicitlyPausedByClick) {
var now = Date.now(); // Unconditionally keep audio stream active
if (videoState.pausedAt && now - videoState.pausedAt > 1500 && videoState.pausedByUser) {
return;
}
// Resume playback when screen locks or tab switches
setTimeout(function () { setTimeout(function () {
if (video.paused && !videoState.pausedByUser) { if (video.paused && !videoState.explicitlyPausedByClick) {
video.play().catch(function () {}); video.play().catch(function () {});
} }
}, 50); }, 100);
setTimeout(function () {
if (video.paused && !videoState.explicitlyPausedByClick) {
video.play().catch(function () {});
}
}, 300);
}
}
} }
document.addEventListener('visibilitychange', handleVisibilityChange, false); document.addEventListener('visibilitychange', handleVisibilityChange, false);
document.addEventListener('webkitvisibilitychange', handleVisibilityChange, false); document.addEventListener('webkitvisibilitychange', handleVisibilityChange, false);
window.addEventListener('pagehide', handleVisibilityChange, false);
// MediaSession API Integration (Lock Screen, Bluetooth, Smart Watches) // MediaSession API Integration (Lock Screen, Bluetooth, Smart Watches)
function updateMediaSessionMetadata(video) { function updateMediaSessionMetadata(video) {
@@ -3125,4 +3204,7 @@
var video = getVideoElement(); var video = getVideoElement();
if (video) attachVideoListeners(video); if (video) attachVideoListeners(video);
}, 1000); }, 1000);
})(); })();
} catch (err) {
console.error('[YakTube] Safe catch error:', err);
}
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "peertube-plugin-yaktube-ondemand", "name": "peertube-plugin-yaktube-ondemand",
"version": "1.4.9", "version": "1.4.15",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube",
"main": "main.js", "main": "main.js",
"library": "./main.js", "library": "./main.js",
+26
View File
@@ -1,3 +1,29 @@
/* Permanent Aggressive Suppression of Generic JoinPeerTube / Framasoft Open-in-App Banners */
my-open-app,
my-open-in-app,
my-client-app-banner,
.open-app-container,
.app-banner,
[class*='open-app'],
[class*='open-in-app'],
.mobile-app-banner,
.app-promotion,
.client-app-banner,
a[href*='play.google.com/store/apps/details?id=app.joinpeertube'],
a[href*='f-droid.org'],
a[href*='joinpeertube'] {
display: none !important;
visibility: hidden !important;
height: 0 !important;
width: 0 !important;
margin: 0 !important;
padding: 0 !important;
pointer-events: none !important;
opacity: 0 !important;
position: absolute !important;
z-index: -99999 !important;
}
/* YakTube Accessibility & On-Demand CSS */ /* YakTube Accessibility & On-Demand CSS */
:focus-visible { :focus-visible {