diff --git a/client.js b/client.js index e9dffb1..835faed 100644 --- a/client.js +++ b/client.js @@ -1,3 +1,11 @@ + + // Immediate URL rewrite: redirect legacy /search/videos to /search + if (typeof window !== 'undefined' && window.location) { + if (window.location.pathname === '/search/videos' || window.location.pathname.startsWith('/search/videos/')) { + var targetSearch = window.location.search || ''; + window.location.replace('/search' + targetSearch); + } + } try { (function () { if (window.__YAKTUBE_ENGINE_LOADED__) return; @@ -1626,6 +1634,18 @@ try { } function checkAndInjectSearchResults() { + // Clean up stray 404 error mascot pages if on search + try { + var errPages = document.querySelectorAll('my-error-page'); + errPages.forEach(function(ep) { ep.remove(); }); + } catch (e) {} + + // Instant URL fixer: redirect legacy /search/videos to native /search + if (window.location.pathname === '/search/videos' || window.location.pathname.startsWith('/search/videos/')) { + window.location.replace('/search' + window.location.search); + return; + } + var url = new URL(window.location.href); var searchParam = url.searchParams.get('search'); @@ -2126,7 +2146,7 @@ try { saveRecentSearch(q); announce('"' + q + '" için arama yapılıyor...', true); closeFullSearchModal(); - window.location.href = '/search/videos?search=' + encodeURIComponent(q); + window.location.href = '/search?search=' + encodeURIComponent(q); } } window.__yaktube_execute_search__ = executeSearch; @@ -2257,7 +2277,7 @@ try { announce('"' + transcript + '" için arama başlatılıyor...', true); setTimeout(function () { closeFullSearchModal(); - window.location.href = '/search/videos?search=' + encodeURIComponent(transcript); + window.location.href = '/search?search=' + encodeURIComponent(transcript); }, 500); } } diff --git a/package.json b/package.json index 312bece..f376c64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-yaktube-ondemand", - "version": "1.4.20", + "version": "1.4.21", "description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations and A11y Engine for PeerTube", "main": "main.js", "library": "./main.js", @@ -44,4 +44,4 @@ "homepage": "https://yaktube.yakhub.com.tr", "bugs": "https://github.com/yakistir98/peertube-plugin-yaktube-ondemand/issues", "license": "AGPL-3.0-or-later" -} +} \ No newline at end of file diff --git a/style.css b/style.css index 1a21330..fd3a3f9 100644 --- a/style.css +++ b/style.css @@ -942,3 +942,18 @@ body.yaktube-theater-mode .video-js { color: #fff !important; outline: none !important; } + + +/* Suppress 404 Mascot and Error Page on Search results */ +body:has(#yaktube-ondemand-container) my-error-page, +#yaktube-ondemand-container ~ my-error-page, +my-error-page:has(~ #yaktube-ondemand-container), +my-error-page { + /* Only hide if search param is active */ +} +body:has(#yaktube-ondemand-container) my-error-page { + display: none !important; + visibility: hidden !important; + height: 0 !important; + overflow: hidden !important; +}