Compare commits

...
7 Commits
3 changed files with 614 additions and 149 deletions
+555 -145
View File
@@ -152,6 +152,117 @@
true
);
// 2.3 Dedicated Local Admin Login Modal (Alt+A)
function openLocalAdminLoginModal() {
var existingModal = document.getElementById('yaktube-admin-login-modal');
if (existingModal) {
existingModal.style.display = 'flex';
var uInput = existingModal.querySelector('#yaktube-admin-username');
if (uInput) uInput.focus();
return;
}
var modal = document.createElement('div');
modal.id = 'yaktube-admin-login-modal';
modal.className = 'yaktube-modal-overlay';
modal.setAttribute('role', 'dialog');
modal.setAttribute('aria-modal', 'true');
modal.setAttribute('aria-labelledby', 'yaktube-admin-modal-title');
modal.innerHTML =
'<div class="yaktube-modal-card" style="max-width: 420px; background:#181824; border:1px solid rgba(255,143,55,0.4); border-radius:18px; padding:26px; color:#fff; box-shadow:0 16px 40px rgba(0,0,0,0.8); text-align:left;">' +
'<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:18px;">' +
'<h3 id="yaktube-admin-modal-title" style="margin:0; font-size:18px; color:#ff8f37;">⚙️ Sunucu Yöneticisi Girişi</h3>' +
'<button id="yaktube-admin-modal-close" class="yaktube-voice-modal-close-btn" aria-label="Kapat">✕</button>' +
'</div>' +
'<p style="font-size:13px; color:#aaa; margin-bottom:16px;">Yerel yönetici (admin) kullanıcı adı ve şifrenizle giriş yaparak PeerTube yönetim paneline erişebilirsiniz.</p>' +
'<form id="yaktube-admin-direct-form" style="display:flex; flex-direction:column; gap:12px;">' +
'<div style="display:flex; flex-direction:column; gap:4px;">' +
'<label for="yaktube-admin-username" style="font-size:13px; font-weight:600; color:#ddd;">Kullanıcı Adı veya E-posta:</label>' +
'<input type="text" id="yaktube-admin-username" required style="background:#22222e; border:1px solid #444; border-radius:8px; padding:10px 12px; color:#fff; font-size:14px; outline:none;" />' +
'</div>' +
'<div style="display:flex; flex-direction:column; gap:4px;">' +
'<label for="yaktube-admin-password" style="font-size:13px; font-weight:600; color:#ddd;">Şifre:</label>' +
'<input type="password" id="yaktube-admin-password" required style="background:#22222e; border:1px solid #444; border-radius:8px; padding:10px 12px; color:#fff; font-size:14px; outline:none;" />' +
'</div>' +
'<div id="yaktube-admin-login-error" style="color:#ef4444; font-size:13px; display:none; margin-top:4px;"></div>' +
'<button type="submit" id="yaktube-admin-login-submit" style="background:linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%); color:#fff; border:none; border-radius:8px; padding:12px; font-weight:700; font-size:14px; cursor:pointer; margin-top:6px;">Yönetici Olarak Giriş Yap</button>' +
'</form>' +
'</div>';
document.body.appendChild(modal);
modal.querySelector('#yaktube-admin-modal-close').addEventListener('click', function () {
modal.style.display = 'none';
});
modal.addEventListener('click', function (e) {
if (e.target === modal) modal.style.display = 'none';
});
var form = modal.querySelector('#yaktube-admin-direct-form');
var errEl = modal.querySelector('#yaktube-admin-login-error');
var uInput = modal.querySelector('#yaktube-admin-username');
var pInput = modal.querySelector('#yaktube-admin-password');
var sBtn = modal.querySelector('#yaktube-admin-login-submit');
uInput.focus();
form.addEventListener('submit', async function (ev) {
ev.preventDefault();
errEl.style.display = 'none';
sBtn.disabled = true;
sBtn.innerText = 'Giriş Yapılıyor...';
try {
var clientRes = await fetch('/api/v1/oauth-clients/local');
var clientData = await clientRes.json();
var bodyParams = new URLSearchParams({
client_id: clientData.client_id,
client_secret: clientData.client_secret,
grant_type: 'password',
username: uInput.value.trim(),
password: pInput.value
});
var tokenRes = await fetch('/api/v1/users/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: bodyParams.toString()
});
var tokenData = await tokenRes.json();
if (!tokenRes.ok || !tokenData.access_token) {
throw new Error(tokenData.error_description || tokenData.error || 'Kullanıcı adı veya şifre hatalı.');
}
// Store tokens
localStorage.setItem('access_token', tokenData.access_token);
localStorage.setItem('refresh_token', tokenData.refresh_token);
localStorage.setItem('token_type', tokenData.token_type || 'Bearer');
localStorage.setItem('username', uInput.value.trim());
// Get user details
var meRes = await fetch('/api/v1/users/me', {
headers: { Authorization: 'Bearer ' + tokenData.access_token }
});
if (meRes.ok) {
var meData = await meRes.json();
localStorage.setItem('email', meData.email || '');
localStorage.setItem('displayName', meData.displayName || meData.username || '');
}
announce('Yönetici girişi başarılı! Yönetim paneline yönlendiriliyorsunuz.', true);
window.location.href = '/admin';
} catch (err) {
errEl.innerText = err.message;
errEl.style.display = 'block';
sBtn.disabled = false;
sBtn.innerText = 'Yönetici Olarak Giriş Yap';
}
});
}
// 2. YakNet SSO Header & Login Flow
function injectYakNetSSO() {
// 2.1 Header: Place YakNet Account widget in top-right .buttons-container
@@ -172,86 +283,104 @@
var isAuth = !!token && !!uName;
if (headerRight) {
var defaultLoginLink = headerRight.querySelector('my-login-link, a[href*="/login"], .login-button');
var liveWidget = headerRight.querySelector('#yaknet-header-account-widget');
if (!liveWidget) {
var widgetWrap = document.createElement('div');
widgetWrap.id = 'yaknet-header-account-widget';
widgetWrap.className = 'yaknet-header-widget';
widgetWrap.style.display = 'inline-flex';
widgetWrap.style.alignItems = 'center';
widgetWrap.style.marginRight = '8px';
widgetWrap.innerHTML =
'<yaknet-account ' +
'client-id="01a03c41-f758-721e-b927-619bffde5c23" ' +
'redirect-uri="https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback" ' +
'base-url="https://auth.yakhub.com.tr" ' +
'login-url="/login" ' +
'authenticated="' +
(isAuth ? 'true' : 'false') +
'" ' +
'user-name="' +
(isAuth ? displayName.replace(/"/g, '&quot;') : '') +
'" ' +
'user-email="' +
(isAuth ? emailStr.replace(/"/g, '&quot;') : '') +
'" ' +
'theme="dark">' +
'</yaknet-account>';
var targetSibling =
headerRight.querySelector('my-user-menu') ||
headerRight.querySelector('my-login-link') ||
headerRight.querySelector('.user-menu') ||
headerRight.querySelector('.settings-button') ||
headerRight.querySelector('my-user-notifications') ||
headerRight.querySelector('my-notification-bell');
if (targetSibling && targetSibling.parentElement === headerRight) {
headerRight.insertBefore(widgetWrap, targetSibling);
} else {
headerRight.prepend(widgetWrap);
}
var defaultLoginLink = headerRight.querySelector('my-login-link');
if (isAuth) {
// Logged In: Show YakNet Profile Menu, Hide default login link
if (defaultLoginLink) {
defaultLoginLink.setAttribute('aria-hidden', 'true');
defaultLoginLink.setAttribute('tabindex', '-1');
defaultLoginLink.style.display = 'none';
defaultLoginLink.setAttribute('aria-hidden', 'true');
}
} else {
// Sync widget attributes dynamically if auth state changed
var el = liveWidget.querySelector('yaknet-account');
if (el) {
if (el.shadowRoot) {
var shadowLogoutBtn =
el.shadowRoot.getElementById('logoutBtn') ||
el.shadowRoot.querySelector('.yn-logout-btn') ||
el.shadowRoot.querySelector('button[title*="Çıkış"], button[aria-label*="Çıkış"]');
if (shadowLogoutBtn && !shadowLogoutBtn.hasAttribute('data-yaktube-hooked')) {
shadowLogoutBtn.setAttribute('data-yaktube-hooked', 'true');
shadowLogoutBtn.addEventListener(
'click',
function (ev) {
ev.preventDefault();
ev.stopPropagation();
performUnifiedLogout();
},
true
);
if (!liveWidget) {
var widgetWrap = document.createElement('div');
widgetWrap.id = 'yaknet-header-account-widget';
widgetWrap.className = 'yaknet-header-widget';
widgetWrap.style.display = 'inline-flex';
widgetWrap.style.alignItems = 'center';
widgetWrap.style.marginRight = '8px';
widgetWrap.innerHTML =
'<yaknet-account ' +
'client-id="01a03c41-f758-721e-b927-619bffde5c23" ' +
'redirect-uri="https://yaktube.yakhub.com.tr/plugins/peertube-plugin-auth-yaknet/router/auth-callback" ' +
'base-url="https://auth.yakhub.com.tr" ' +
'login-url="/login" ' +
'authenticated="true" ' +
'user-name="' +
displayName.replace(/"/g, '&quot;') +
'" ' +
'user-email="' +
emailStr.replace(/"/g, '&quot;') +
'" ' +
'theme="dark">' +
'</yaknet-account>';
var targetSibling =
headerRight.querySelector('my-user-menu') ||
headerRight.querySelector('.user-menu') ||
headerRight.querySelector('.settings-button') ||
headerRight.querySelector('my-user-notifications') ||
headerRight.querySelector('my-notification-bell');
if (targetSibling && targetSibling.parentElement === headerRight) {
headerRight.insertBefore(widgetWrap, targetSibling);
} else {
headerRight.prepend(widgetWrap);
}
} else {
var el = liveWidget.querySelector('yaknet-account');
if (el) {
if (el.shadowRoot) {
var shadowLogoutBtn =
el.shadowRoot.getElementById('logoutBtn') ||
el.shadowRoot.querySelector('.yn-logout-btn') ||
el.shadowRoot.querySelector('button[title*="Çıkış"], button[aria-label*="Çıkış"]');
if (shadowLogoutBtn && !shadowLogoutBtn.hasAttribute('data-yaktube-hooked')) {
shadowLogoutBtn.setAttribute('data-yaktube-hooked', 'true');
shadowLogoutBtn.addEventListener(
'click',
function (ev) {
ev.preventDefault();
ev.stopPropagation();
performUnifiedLogout();
},
true
);
}
}
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 {
// Not Logged In: Remove YakNet widget to eliminate duplicate button, keep PeerTube native login button clean
if (liveWidget) {
liveWidget.remove();
}
if (defaultLoginLink) {
defaultLoginLink.style.display = '';
defaultLoginLink.removeAttribute('aria-hidden');
var expectedAuth = isAuth ? 'true' : 'false';
var expectedName = isAuth ? displayName : '';
var expectedEmail = isAuth ? emailStr : '';
if (el.getAttribute('authenticated') !== expectedAuth || el.getAttribute('user-name') !== expectedName) {
el.setAttribute('authenticated', expectedAuth);
el.setAttribute('user-name', expectedName);
el.setAttribute('user-email', expectedEmail);
if (typeof el.syncStateFromAttributes === 'function') {
el.syncStateFromAttributes();
el.render();
var loginAnchor =
defaultLoginLink.tagName.toLowerCase() === 'a' ? defaultLoginLink : defaultLoginLink.querySelector('a');
if (loginAnchor) {
loginAnchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
loginAnchor.setAttribute('title', 'YakNet Hesabınız ile Giriş Yapın');
var spanText = loginAnchor.querySelector('span');
if (spanText) {
spanText.textContent = 'YakNet ile Giriş Yap';
} else {
loginAnchor.textContent = 'YakNet ile Giriş Yap';
}
}
}
@@ -326,11 +455,7 @@
if (showAdminBtn) {
showAdminBtn.addEventListener('click', function (e) {
e.preventDefault();
subElements.forEach(function (el) {
el.style.display = '';
});
showAdminBtn.style.display = 'none';
announce('Yönetici kullanıcı adı ve şifre giriş formu açıldı.');
openLocalAdminLoginModal();
});
}
}
@@ -339,8 +464,52 @@
// 3. Intelligent Branding & A11y DOM Auto-Fixer
function autoFixDOM() {
injectAccessiblePlayerBar();
// Check if on 403 / unauthorized page and provide admin login button
var notAuthorizedEl = document.querySelector('my-not-found, .not-found, .forbidden, my-forbidden, .error-page');
if (notAuthorizedEl && !document.getElementById('yaktube-403-admin-btn')) {
var btn403 = document.createElement('div');
btn403.id = 'yaktube-403-admin-btn';
btn403.style.margin = '20px auto';
btn403.style.textAlign = 'center';
btn403.innerHTML =
'<button style="background:linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%); color:#fff; border:none; padding:12px 24px; border-radius:10px; font-weight:700; cursor:pointer; font-size:15px;">🔑 Sunucu Yöneticisi Olarak Giriş Yap (Alt+A)</button>';
btn403.querySelector('button').addEventListener('click', openLocalAdminLoginModal);
notAuthorizedEl.appendChild(btn403);
}
injectYakNetSSO();
// Replace all login buttons labels and titles
document
.querySelectorAll(
'my-login-link, a[href*="/login"], a[title*="Giriş sayfasına git"], [aria-label*="Giriş sayfasına git"]'
)
.forEach(function (el) {
if (el.getAttribute('title') && el.getAttribute('title').includes('Giriş sayfasına git')) {
el.setAttribute('title', 'YakNet ile Giriş Yap');
}
if (el.getAttribute('aria-label') && el.getAttribute('aria-label').includes('Giriş sayfasına git')) {
el.setAttribute('aria-label', 'YakNet ile Giriş Yap');
}
var anchor = el.tagName.toLowerCase() === 'a' ? el : el.querySelector('a');
if (anchor) {
anchor.setAttribute('title', 'YakNet ile Giriş Yap');
anchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
var spans = anchor.querySelectorAll('span');
spans.forEach(function (s) {
if (
s.textContent.includes('Giriş sayfasına git') ||
s.textContent.trim() === 'Giriş' ||
s.textContent.trim() === 'Giriş yap'
) {
s.textContent = 'YakNet ile Giriş Yap';
}
});
}
});
// Aggressively remove generic Framasoft Open-in-App / Play Store banners
var genericAppBanners = document.querySelectorAll(
'my-open-app, my-client-app-banner, .open-app-container, .app-banner, [class*="open-app"], [class*="open-in-app"], .mobile-app-banner, my-open-in-app, .app-promotion, a[href*="play.google.com/store/apps/details?id=app.joinpeertube"], a[href*="f-droid.org"]'
@@ -379,7 +548,8 @@
.replace(/PeerTube hakkında/gi, 'YakTube Hakkında')
.replace(/PeerTube'a katılın/gi, "YakTube'a Katılın")
.replace(/PeerTube örneği/gi, 'YakTube Sunucusu')
.replace(/PeerTube/g, 'YakTube');
.replace(/PeerTube/g, 'YakTube')
.replace(/Giriş sayfasına git/gi, 'YakNet ile Giriş Yap');
}
}
}
@@ -576,7 +746,7 @@
setInterval(autoFixDOM, 1000);
// 3. Keyboard Shortcuts Modal & Quick Info Engine (v1.4.0)
// 3. Screen-Reader & Turkish Q Optimized Shortcuts & Player Bar (v1.4.1)
function toggleShortcutsModal() {
var modal = document.getElementById('yaktube-shortcuts-dialog');
if (modal) {
@@ -597,27 +767,27 @@
modal.setAttribute('aria-modal', 'true');
modal.setAttribute('aria-labelledby', 'yaktube-shortcuts-title');
modal.innerHTML =
'<div class="yaktube-modal-card" style="max-width: 560px; background:#1e1e24; border-radius:18px; padding:24px; color:#fff; box-shadow:0 16px 40px rgba(0,0,0,0.8);">' +
'<div class="yaktube-modal-card" style="max-width: 600px; background:#1e1e24; border-radius:18px; padding:24px; color:#fff; box-shadow:0 16px 40px rgba(0,0,0,0.8);">' +
'<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:16px;">' +
'<h3 id="yaktube-shortcuts-title" style="margin:0; font-size:18px; color:#ff8f37;">⌨️ Video Oynatıcı & Gezinme Kısayolları</h3>' +
'<h3 id="yaktube-shortcuts-title" style="margin:0; font-size:18px; color:#ff8f37;">⌨️ Klavye Kısayolları (Ekran Okuyucu Uyumlu)</h3>' +
'<button id="yaktube-shortcuts-close" class="yaktube-voice-modal-close-btn" aria-label="Kapat">✕</button>' +
'</div>' +
'<div style="font-size:12px; color:#aaa; margin-bottom:14px;">💡 <b>Ekran Okuyucu Notu:</b> Sanal imleç (Browse mode) açıkken kısayolları <b>Alt</b> tuşuyla birlikte kullanabilir veya video oynatıcı butonlarından faydalanabilirsiniz.</div>' +
'<table class="yaktube-shortcuts-table" style="width:100%; border-collapse:collapse; font-size:13px;">' +
'<thead><tr style="border-bottom:1px solid rgba(255,255,255,0.1); text-align:left; color:#aaa;"><th style="padding:6px 0;">Kısayol</th><th style="padding:6px 0;">İşlev</th></tr></thead>' +
'<thead><tr style="border-bottom:1px solid rgba(255,255,255,0.1); text-align:left; color:#aaa;"><th style="padding:6px 0;">Kısayol (Evrensel / Tek Tuş)</th><th style="padding:6px 0;">İşlev</th></tr></thead>' +
'<tbody>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Space</span> veya <span class="yaktube-kbd">K</span></td><td>Oynat / Duraklat</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">J</span> / <span class="yaktube-kbd">L</span></td><td>10 saniye geri / ileri sar</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Sol</span> / <span class="yaktube-kbd">Sağ Ok</span></td><td>5 saniye geri / ileri sar</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Yukarı</span> / <span class="yaktube-kbd">Aşağı Ok</span></td><td>Sesi %5 artır / azalt</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">M</span></td><td>Sesi Kapat / Aç (Mute)</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">F</span></td><td>Tam Ekran</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">T</span></td><td>Sinema / Tiyatro Modu</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">C</span></td><td>Altyazıları Aç / Kapat</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">I</span></td><td>Hızlı Video Bilgisi & İstatistikler</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">&gt;</span> / <span class="yaktube-kbd">&lt;</span> (Shift+.)</td><td>Oynatma hızını artır / azalt</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">0 - 9</span></td><td>Videonun %0 - %90 noktasına atla</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">/</span></td><td>Arama penceresini aç</td></tr>' +
'<tr><td style="padding:8px 0;"><span class="yaktube-kbd">Shift + V</span></td><td>Sesli aramayı başlat</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + K</span> veya <span class="yaktube-kbd">Space</span></td><td>Oynat / Duraklat</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + J</span> veya <span class="yaktube-kbd">J</span></td><td>10 saniye geri sar</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + L</span> veya <span class="yaktube-kbd">L</span></td><td>10 saniye ileri sar</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + Yukarı / Aşağı</span></td><td>Sesi %5 artır / azalt</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + M</span> veya <span class="yaktube-kbd">M</span></td><td>Sesi Kapat / Aç (Mute)</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + T</span> veya <span class="yaktube-kbd">T</span></td><td>Sinema / Tiyatro Modu</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + I</span> veya <span class="yaktube-kbd">I</span></td><td>Hızlı Video Bilgisi & İstatistikler</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + C</span> veya <span class="yaktube-kbd">C</span></td><td>Altyazıları Aç / Kapat</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + .</span> / <span class="yaktube-kbd">Alt + ,</span></td><td>Oynatma hızını artır / azalt</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + S</span> veya <span class="yaktube-kbd">/</span> (Shift+7)</td><td>Arama penceresini aç</td></tr>' +
'<tr style="border-bottom:1px solid rgba(255,255,255,0.05);"><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + V</span> veya <span class="yaktube-kbd">Shift + V</span></td><td>Sesli aramayı başlat</td></tr>' +
'<tr><td style="padding:8px 0;"><span class="yaktube-kbd">Alt + H</span> veya <span class="yaktube-kbd">F1</span> veya <span class="yaktube-kbd">?</span></td><td>Bu kılavuzu aç / kapat</td></tr>' +
'</tbody>' +
'</table>' +
'</div>';
@@ -668,8 +838,8 @@
var curTime = formatTime(video.currentTime);
var totalTime = formatTime(video.duration || 0);
var remaining = formatTime((video.duration || 0) - video.currentTime);
var speed = video.playbackRate + 'x';
var volume = Math.round(video.volume * 100) + '%';
var speed = (video.playbackRate || 1) + 'x';
var volume = Math.round((video.volume || 1) * 100) + '%';
var quality = video.videoHeight ? video.videoHeight + 'p' : 'Otomatik';
// Visual Toast
@@ -726,7 +896,111 @@
var speedSteps = [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
// 4. Global Keydown Listener (Pro Video Player Engine)
function adjustPlaybackSpeed(increase) {
var video = getVideoElement();
if (!video) return;
var curSpeed = video.playbackRate || 1;
if (increase) {
var nextIdx = speedSteps.findIndex(function (s) {
return s > curSpeed;
});
video.playbackRate = nextIdx !== -1 ? speedSteps[nextIdx] : 2;
announce('Oynatma hızı ' + video.playbackRate + ' katına çıkarıldı.');
} else {
var prevSteps = speedSteps.filter(function (s) {
return s < curSpeed;
});
video.playbackRate = prevSteps.length > 0 ? prevSteps[prevSteps.length - 1] : 0.25;
announce('Oynatma hızı ' + video.playbackRate + ' katına düşürüldü.');
}
}
// 3.1. Injects Accessible Player Action Bar under the Watch Video
function injectAccessiblePlayerBar() {
if (!window.location.pathname.includes('/videos/watch/')) return;
var video = getVideoElement();
if (!video) return;
var targetContainer = document.querySelector(
'my-video-watch, .video-watch, .watch-container, #yaktube-ondemand-container'
);
if (!targetContainer) return;
var existingBar = document.getElementById('yaktube-player-action-bar');
if (existingBar) return;
var bar = document.createElement('div');
bar.id = 'yaktube-player-action-bar';
bar.className = 'yaktube-player-action-bar';
bar.setAttribute('role', 'toolbar');
bar.setAttribute('aria-label', 'Erişilebilir Video Kontrolleri');
bar.innerHTML =
'<span class="yaktube-player-bar-label">⚡ Oynatıcı Kontrolleri:</span>' +
'<button id="yaktube-bar-rewind-btn" class="yaktube-player-action-btn" aria-label="10 Saniye Geri Sar (Alt+J)">⏪ 10sn Geri</button>' +
'<button id="yaktube-bar-play-btn" class="yaktube-player-action-btn" aria-label="Oynat veya Duraklat (Alt+K)">⏯️ Oynat/Duraklat</button>' +
'<button id="yaktube-bar-forward-btn" class="yaktube-player-action-btn" aria-label="10 Saniye İleri Sar (Alt+L)">⏩ 10sn İleri</button>' +
'<button id="yaktube-bar-speed-btn" class="yaktube-player-action-btn" aria-label="Oynatma Hızını Değiştir (Alt+.)">⚡ Hız</button>' +
'<button id="yaktube-bar-theater-btn" class="yaktube-player-action-btn" aria-label="Sinema Modunu Aç/Kapat (Alt+T)">🎭 Sinema</button>' +
'<button id="yaktube-bar-info-btn" class="yaktube-player-action-btn" aria-label="Video Bilgisi ve İstatistikleri (Alt+I)">📊 Bilgi</button>' +
'<button id="yaktube-bar-help-btn" class="yaktube-player-action-btn" aria-label="Kısayol Kılavuzu (Alt+H veya F1)">⌨️ Kısayollar</button>';
var playerWrap =
document.querySelector('.player-container, .video-player-container, .player-wrapper, my-video-watch .player') ||
targetContainer;
if (playerWrap && playerWrap.nextSibling) {
playerWrap.parentNode.insertBefore(bar, playerWrap.nextSibling);
} else {
targetContainer.prepend(bar);
}
// Attach button actions
bar.querySelector('#yaktube-bar-rewind-btn').addEventListener('click', function () {
if (video) {
video.currentTime = Math.max(0, video.currentTime - 10);
announce('10 saniye geri sarıldı. Konum: ' + formatTime(video.currentTime));
}
});
bar.querySelector('#yaktube-bar-play-btn').addEventListener('click', function () {
if (video) {
if (video.paused) {
video.play();
announce('Video oynatılıyor.');
} else {
video.pause();
announce('Video duraklatıldı.');
}
}
});
bar.querySelector('#yaktube-bar-forward-btn').addEventListener('click', function () {
if (video) {
video.currentTime = Math.min(video.duration || 99999, video.currentTime + 10);
announce('10 saniye ileri sarıldı. Konum: ' + formatTime(video.currentTime));
}
});
bar.querySelector('#yaktube-bar-speed-btn').addEventListener('click', function () {
adjustPlaybackSpeed(true);
});
bar.querySelector('#yaktube-bar-theater-btn').addEventListener('click', function () {
document.body.classList.toggle('yaktube-theater-mode');
var isT = document.body.classList.contains('yaktube-theater-mode');
announce(isT ? 'Sinema modu açıldı.' : 'Sinema modundan çıkıldı.');
});
bar.querySelector('#yaktube-bar-info-btn').addEventListener('click', function () {
showQuickVideoInfo();
});
bar.querySelector('#yaktube-bar-help-btn').addEventListener('click', function () {
toggleShortcutsModal();
});
}
// 4. Global Keydown Listener (Screen-Reader & Turkish Q Optimized)
window.addEventListener('keydown', function (e) {
if (e.key === 'Escape') {
var shortcutsModal = document.getElementById('yaktube-shortcuts-dialog');
@@ -747,7 +1021,15 @@
return;
}
if (e.key === '?' || (e.shiftKey && e.key === '/')) {
// Admin Login: Alt+A
if (e.altKey && (e.key === 'a' || e.key === 'A') && !isInputFocused()) {
e.preventDefault();
openLocalAdminLoginModal();
return;
}
// Help Dialog: Alt+H, F1 or '?' key
if ((e.altKey && (e.key === 'h' || e.key === 'H')) || e.key === 'F1' || e.key === '?') {
if (!isInputFocused()) {
e.preventDefault();
toggleShortcutsModal();
@@ -755,6 +1037,28 @@
}
}
// Search Open: Alt+S, Ctrl+K or '/' key (Turkish Q Shift+7)
if (
((e.altKey && (e.key === 's' || e.key === 'S')) ||
(e.ctrlKey && (e.key === 'k' || e.key === 'K')) ||
e.key === '/') &&
!isInputFocused()
) {
e.preventDefault();
openFullSearchModal('', false);
return;
}
// Voice Search Open: Alt+V or Shift+V
if (
((e.altKey && (e.key === 'v' || e.key === 'V')) || (e.shiftKey && (e.key === 'v' || e.key === 'V'))) &&
!isInputFocused()
) {
e.preventDefault();
openFullSearchModal('', true);
return;
}
if (isInputFocused()) {
return;
}
@@ -763,9 +1067,10 @@
if (!video) return;
var key = e.key.toLowerCase();
var alt = e.altKey;
// Play / Pause (Space / K)
if (key === ' ' || key === 'k') {
// Play / Pause (Alt+K, Space or K)
if (key === ' ' || key === 'k' || (alt && key === 'k')) {
e.preventDefault();
if (video.paused) {
video.play();
@@ -775,44 +1080,44 @@
announce('Video duraklatıldı.');
}
}
// Seek 10s Back / Forward (J / L)
else if (key === 'j') {
// Seek 10s Back / Forward (Alt+J / Alt+L or J / L)
else if (key === 'j' || (alt && key === 'j')) {
e.preventDefault();
video.currentTime = Math.max(0, video.currentTime - 10);
announce('10 saniye geri sarıldı. Konum: ' + formatTime(video.currentTime));
} else if (key === 'l') {
} else if (key === 'l' || (alt && key === 'l')) {
e.preventDefault();
video.currentTime = Math.min(video.duration || 99999, video.currentTime + 10);
announce('10 saniye ileri sarıldı. Konum: ' + formatTime(video.currentTime));
}
// Seek 5s Back / Forward (Left / Right Arrow)
else if (e.key === 'ArrowLeft') {
// Seek 5s Back / Forward (ArrowLeft / ArrowRight or Alt+Left/Right)
else if (e.key === 'ArrowLeft' || (alt && e.key === 'ArrowLeft')) {
e.preventDefault();
video.currentTime = Math.max(0, video.currentTime - 5);
announce('5 saniye geri sarıldı. Konum: ' + formatTime(video.currentTime));
} else if (e.key === 'ArrowRight') {
} else if (e.key === 'ArrowRight' || (alt && e.key === 'ArrowRight')) {
e.preventDefault();
video.currentTime = Math.min(video.duration || 99999, video.currentTime + 5);
announce('5 saniye ileri sarıldı. Konum: ' + formatTime(video.currentTime));
}
// Volume Up / Down (Up / Down Arrow)
else if (e.key === 'ArrowUp') {
// Volume Up / Down (ArrowUp / ArrowDown or Alt+Up/Down)
else if (e.key === 'ArrowUp' || (alt && e.key === 'ArrowUp')) {
e.preventDefault();
video.volume = Math.min(1, video.volume + 0.05);
video.volume = Math.min(1, (video.volume || 1) + 0.05);
announce('Ses seviyesi yüzde ' + Math.round(video.volume * 100));
} else if (e.key === 'ArrowDown') {
} else if (e.key === 'ArrowDown' || (alt && e.key === 'ArrowDown')) {
e.preventDefault();
video.volume = Math.max(0, video.volume - 0.05);
video.volume = Math.max(0, (video.volume || 1) - 0.05);
announce('Ses seviyesi yüzde ' + Math.round(video.volume * 100));
}
// Mute (M)
else if (key === 'm') {
// Mute (Alt+M or M)
else if (key === 'm' || (alt && key === 'm')) {
e.preventDefault();
video.muted = !video.muted;
announce(video.muted ? 'Ses kapatıldı (Sessiz).' : 'Ses açıldı.');
}
// Fullscreen (F)
else if (key === 'f') {
// Fullscreen (Alt+F or F)
else if (key === 'f' || (alt && key === 'f')) {
e.preventDefault();
if (!document.fullscreenElement) {
var container = video.closest('.video-js') || video.parentElement || video;
@@ -823,20 +1128,20 @@
announce('Tam ekrandan çıkıldı.');
}
}
// Theater Mode (T)
else if (key === 't') {
// Theater Mode (Alt+T or T)
else if (key === 't' || (alt && key === 't')) {
e.preventDefault();
document.body.classList.toggle('yaktube-theater-mode');
var isTheater = document.body.classList.contains('yaktube-theater-mode');
announce(isTheater ? 'Sinema modu açıldı.' : 'Sinema modundan çıkıldı.');
}
// Quick Video Info (I)
else if (key === 'i') {
// Quick Video Info (Alt+I or I)
else if (key === 'i' || (alt && key === 'i')) {
e.preventDefault();
showQuickVideoInfo();
}
// Subtitles (C)
else if (key === 'c') {
// Subtitles (Alt+C or C)
else if (key === 'c' || (alt && key === 'c')) {
e.preventDefault();
var tracks = video.textTracks;
if (tracks && tracks.length > 0) {
@@ -847,31 +1152,13 @@
announce('Bu videoda altyazı bulunmuyor.');
}
}
// Speed Controls (< and > / Shift+, and Shift+.)
else if (e.key === '>' || (e.shiftKey && e.key === '.')) {
// Speed Controls (Alt+. / Alt+, or > / <)
else if ((alt && (e.key === '.' || e.key === '>')) || e.key === '>') {
e.preventDefault();
var curSpeed = video.playbackRate || 1;
var nextIdx = speedSteps.findIndex(function (s) {
return s > curSpeed;
});
if (nextIdx !== -1) {
video.playbackRate = speedSteps[nextIdx];
} else {
video.playbackRate = 2;
}
announce('Oynatma hızı ' + video.playbackRate + ' katına çıkarıldı.');
} else if (e.key === '<' || (e.shiftKey && e.key === ',')) {
adjustPlaybackSpeed(true);
} else if ((alt && (e.key === ',' || e.key === '<')) || e.key === '<') {
e.preventDefault();
var curSpeed = video.playbackRate || 1;
var prevSteps = speedSteps.filter(function (s) {
return s < curSpeed;
});
if (prevSteps.length > 0) {
video.playbackRate = prevSteps[prevSteps.length - 1];
} else {
video.playbackRate = 0.25;
}
announce('Oynatma hızı ' + video.playbackRate + ' katına düşürüldü.');
adjustPlaybackSpeed(false);
}
// Percentage Jumps (0 - 9)
else if (key >= '0' && key <= '9' && !e.ctrlKey && !e.altKey && !e.metaKey) {
@@ -1536,6 +1823,125 @@
var activeVoiceRec = null;
var isVoiceListening = false;
// Dynamic Search History & Trending Helpers
function getRecentSearches() {
try {
var data = localStorage.getItem('yaktube_recent_searches');
return data ? JSON.parse(data) : [];
} catch (e) {
return [];
}
}
function saveRecentSearch(query) {
if (!query || query.trim().length < 2) return;
var q = query.trim();
try {
var list = getRecentSearches();
list = list.filter(function (item) {
return item.toLowerCase() !== q.toLowerCase();
});
list.unshift(q);
if (list.length > 8) list = list.slice(0, 8);
localStorage.setItem('yaktube_recent_searches', JSON.stringify(list));
} catch (e) {}
}
function clearRecentSearches() {
try {
localStorage.removeItem('yaktube_recent_searches');
} catch (e) {}
renderDynamicSearchChips();
announce('Arama geçmişi temizlendi.');
}
var popularTrendingQueries = [
{ title: '🎵 Türkçe Pop', q: 'Türkçe Pop' },
{ title: '🎸 Anadolu Rock', q: 'Anadolu Rock' },
{ title: '🤖 Yapay Zeka', q: 'Yapay Zeka' },
{ title: '💻 Yazılım Dersleri', q: 'Yazılım Dersleri' },
{ title: '🎧 Sesli Kitap & Radyo Tiyatrosu', q: 'Sesli Kitap' },
{ title: '📺 Canlı Haber', q: 'Canlı Haber' },
{ title: '🌍 Bilim & Belgesel', q: 'Bilim Belgeseli' },
{ title: '🎼 Akustik Canlı Performans', q: 'Akustik Canlı' },
{ title: '🎙️ Podcast & Söyleşi', q: 'Podcast Türkçe' }
];
function renderDynamicSearchChips() {
var modal = document.getElementById('yaktube-full-search-modal');
if (!modal) return;
var container = modal.querySelector('#yaktube-modal-dynamic-chips-section');
if (!container) return;
var recent = getRecentSearches();
var html = '';
// 1. Recent searches section (if any)
if (recent.length > 0) {
html +=
'<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">' +
'<div class="yaktube-modal-section-title" style="margin-bottom: 0;">🕒 Son Aramalarınız</div>' +
'<button id="yaktube-clear-recent-btn" style="background: transparent; border: none; color: #ff8f37; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: underline;" aria-label="Arama geçmişini temizle">Geçmişi Temizle</button>' +
'</div>' +
'<div class="yaktube-modal-chips-grid" style="margin-bottom: 18px;">';
recent.forEach(function (term) {
var safeTerm = term.replace(/"/g, '&quot;');
html +=
'<button class="yaktube-modal-chip yaktube-recent-chip" data-query="' +
safeTerm +
'" aria-label="Son arama: ' +
safeTerm +
'">🕒 ' +
safeTerm +
'</button>';
});
html += '</div>';
}
// 2. Popular & Trending searches section
html +=
'<div class="yaktube-modal-section-title">🔥 Hızlı ve Popüler Aramalar</div>' +
'<div class="yaktube-modal-chips-grid">';
popularTrendingQueries.forEach(function (item) {
var safeQ = item.q.replace(/"/g, '&quot;');
html +=
'<button class="yaktube-modal-chip" data-query="' +
safeQ +
'" aria-label="Popüler arama: ' +
safeQ +
'">' +
item.title +
'</button>';
});
html += '</div>';
container.innerHTML = html;
// Attach click events
container.querySelectorAll('.yaktube-modal-chip').forEach(function (chip) {
chip.addEventListener('click', function () {
var query = chip.getAttribute('data-query');
var inp = modal.querySelector('#yaktube-modal-input');
if (inp) inp.value = query;
if (typeof window.__yaktube_execute_search__ === 'function') {
window.__yaktube_execute_search__(query);
}
});
});
var clearBtn = container.querySelector('#yaktube-clear-recent-btn');
if (clearBtn) {
clearBtn.addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
clearRecentSearches();
});
}
}
function createFullSearchModal() {
var existingModal = document.getElementById('yaktube-full-search-modal');
if (existingModal) return existingModal;
@@ -1624,11 +2030,14 @@
function executeSearch(query) {
var q = (query || inp.value || '').trim();
if (q) {
saveRecentSearch(q);
announce('"' + q + '" için arama yapılıyor...', true);
closeFullSearchModal();
window.location.href = '/search/videos?search=' + encodeURIComponent(q);
}
}
window.__yaktube_execute_search__ = executeSearch;
renderDynamicSearchChips();
submitBtn.addEventListener('click', function () {
executeSearch();
@@ -1668,6 +2077,7 @@
var modal = createFullSearchModal();
modal.classList.add('yaktube-modal-open');
modal.style.display = 'flex';
renderDynamicSearchChips();
var inp = modal.querySelector('#yaktube-modal-input');
var clearBtn = modal.querySelector('#yaktube-modal-clear-btn');
+8 -4
View File
@@ -1,14 +1,17 @@
{
"name": "peertube-plugin-yaktube-ondemand",
"version": "1.4.0",
"version": "1.4.6",
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube",
"main": "main.js",
"library": "./main.js",
"staticDirs": {},
"translations": {},
"clientScripts": [
{
"script": "client.js",
"scopes": [
"common"
],
"script": "client.js"
]
}
],
"css": [
@@ -36,8 +39,9 @@
"author": "Enes Yakıştır <[email protected]>",
"repository": {
"type": "git",
"url": "https://github.com/enesyakistir/peertube-plugin-yaktube-ondemand.git"
"url": "https://github.com/yakistir98/peertube-plugin-yaktube-ondemand.git"
},
"homepage": "https://yaktube.yakhub.com.tr",
"bugs": "https://github.com/yakistir98/peertube-plugin-yaktube-ondemand/issues",
"license": "AGPL-3.0-or-later"
}
+51
View File
@@ -843,3 +843,54 @@ body.yaktube-theater-mode .video-js {
.yaktube-info-toast-row b {
color: #fff !important;
}
/* -------------------------------------------------------------------------- */
/* ACCESSIBLE PLAYER ACTION BAR & SHORTCUTS (v1.4.1) */
/* -------------------------------------------------------------------------- */
.yaktube-player-action-bar {
display: flex !important;
flex-wrap: wrap !important;
gap: 8px !important;
align-items: center !important;
background: #181820 !important;
border: 1px solid rgba(255, 255, 255, 0.1) !important;
border-radius: 12px !important;
padding: 10px 14px !important;
margin: 12px 0 16px 0 !important;
width: 100% !important;
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
}
.yaktube-player-bar-label {
font-size: 13px !important;
font-weight: 700 !important;
color: #ff8f37 !important;
margin-right: 6px !important;
display: flex !important;
align-items: center !important;
gap: 4px !important;
}
.yaktube-player-action-btn {
background: #252530 !important;
color: #f1f1f1 !important;
border: 1px solid rgba(255, 255, 255, 0.1) !important;
border-radius: 8px !important;
padding: 6px 12px !important;
font-size: 13px !important;
font-weight: 600 !important;
cursor: pointer !important;
display: inline-flex !important;
align-items: center !important;
gap: 6px !important;
transition: all 0.2s ease !important;
}
.yaktube-player-action-btn:hover,
.yaktube-player-action-btn:focus {
background: rgba(255, 143, 55, 0.2) !important;
border-color: #ff8f37 !important;
color: #fff !important;
outline: none !important;
}