fix(compatibility): safe matchMedia check and wrap client in try-catch to prevent incompatible browser screen v1.4.10

This commit is contained in:
Enes Yakıştır
2026-08-31 18:48:19 +03:00
parent 15361a21b6
commit dac3137330
2 changed files with 2987 additions and 2967 deletions
+29 -9
View File
@@ -1,3 +1,4 @@
try {
(function () { (function () {
if (window.__YAKTUBE_ENGINE_LOADED__) return; if (window.__YAKTUBE_ENGINE_LOADED__) return;
window.__YAKTUBE_ENGINE_LOADED__ = true; window.__YAKTUBE_ENGINE_LOADED__ = true;
@@ -443,7 +444,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 +672,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 +1504,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 +2230,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 +2499,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 +2778,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 +2857,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);
@@ -3126,3 +3143,6 @@
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.10",
"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",