From b952663f3a77c94437f5a5433ce202361fed2900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Yak=C4=B1=C5=9Ft=C4=B1r?= Date: Fri, 4 Sep 2026 12:54:11 +0300 Subject: [PATCH] Format codebase with Prettier --- .prettierignore | 4 ++ .prettierrc | 9 ++++ client.js | 123 ++++++++++++++++++++++++++---------------------- package.json | 2 +- style.css | 3 +- 5 files changed, 81 insertions(+), 60 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..85a6669 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +package-lock.json +pnpm-lock.yaml diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..e2ac26f --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "none", + "printWidth": 120, + "arrowParens": "avoid", + "endOfLine": "auto" +} diff --git a/client.js b/client.js index f8a7ed5..8340ffd 100644 --- a/client.js +++ b/client.js @@ -1,48 +1,47 @@ - - // 100% Incompatible Browser Suppression & Error Guardian - // CRITICAL: PeerTube's Angular app (my-app ngOnInit) relies on document.getElementById('incompatible-browser') - // to exist so it can do .className += " browser-ok" before calling this.loadUser()! - // Removing it from DOM causes a null pointer crash that breaks user session initialization! - if (typeof window !== 'undefined') { - try { - window.displayIncompatibleBrowser = function () {}; - var neuterIncompatible = function () { - var el = document.getElementById('incompatible-browser'); - if (el) { - if (!el.classList.contains('browser-ok')) { - el.classList.add('browser-ok'); - } - el.style.setProperty('display', 'none', 'important'); - el.style.setProperty('visibility', 'hidden', 'important'); - el.style.setProperty('height', '0px', 'important'); - el.style.setProperty('width', '0px', 'important'); - el.style.setProperty('opacity', '0', 'important'); - el.style.setProperty('pointer-events', 'none', 'important'); - } else { - try { - var dummy = document.createElement('div'); - dummy.id = 'incompatible-browser'; - dummy.className = 'browser-ok'; - dummy.style.display = 'none'; - (document.body || document.documentElement).appendChild(dummy); - } catch (e) {} +// 100% Incompatible Browser Suppression & Error Guardian +// CRITICAL: PeerTube's Angular app (my-app ngOnInit) relies on document.getElementById('incompatible-browser') +// to exist so it can do .className += " browser-ok" before calling this.loadUser()! +// Removing it from DOM causes a null pointer crash that breaks user session initialization! +if (typeof window !== 'undefined') { + try { + window.displayIncompatibleBrowser = function () {}; + var neuterIncompatible = function () { + var el = document.getElementById('incompatible-browser'); + if (el) { + if (!el.classList.contains('browser-ok')) { + el.classList.add('browser-ok'); } - }; - neuterIncompatible(); - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', neuterIncompatible); + el.style.setProperty('display', 'none', 'important'); + el.style.setProperty('visibility', 'hidden', 'important'); + el.style.setProperty('height', '0px', 'important'); + el.style.setProperty('width', '0px', 'important'); + el.style.setProperty('opacity', '0', 'important'); + el.style.setProperty('pointer-events', 'none', 'important'); + } else { + try { + var dummy = document.createElement('div'); + dummy.id = 'incompatible-browser'; + dummy.className = 'browser-ok'; + dummy.style.display = 'none'; + (document.body || document.documentElement).appendChild(dummy); + } catch (e) {} } - setInterval(neuterIncompatible, 1000); - } catch (e) {} - } - - // 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); + }; + neuterIncompatible(); + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', neuterIncompatible); } + setInterval(neuterIncompatible, 1000); + } catch (e) {} +} + +// 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; @@ -1694,14 +1693,16 @@ try { // Clean up stray 404 error mascot pages if on search try { var errPages = document.querySelectorAll('my-error-page'); - errPages.forEach(function(ep) { ep.remove(); }); + 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; - } + // 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'); @@ -2053,7 +2054,9 @@ try { .catch(function () { // Fallback to local PeerTube bridge proxy fetch(bridgeUrl, options) - .then(function (res) { return res.json(); }) + .then(function (res) { + return res.json(); + }) .then(function (data) { if (typeof onSuccess === 'function') onSuccess(data); }) @@ -2068,17 +2071,23 @@ try { if (!isAccountSyncEnabled() || isSyncingHistory) return; isSyncingHistory = true; - callCloudSearchHistory('GET', '', null, function (data) { - isSyncingHistory = false; - if (data && data.status === 'success' && Array.isArray(data.history)) { - if (data.history.length > 0) { - localStorage.setItem('yaktube_recent_searches', JSON.stringify(data.history)); + callCloudSearchHistory( + 'GET', + '', + null, + function (data) { + isSyncingHistory = false; + if (data && data.status === 'success' && Array.isArray(data.history)) { + if (data.history.length > 0) { + localStorage.setItem('yaktube_recent_searches', JSON.stringify(data.history)); + } + if (typeof callback === 'function') callback(); } - if (typeof callback === 'function') callback(); + }, + function () { + isSyncingHistory = false; } - }, function () { - isSyncingHistory = false; - }); + ); } function saveRecentSearch(query) { diff --git a/package.json b/package.json index 0cf1ded..5e5c8c5 100644 --- a/package.json +++ b/package.json @@ -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 2230afc..5cbda54 100644 --- a/style.css +++ b/style.css @@ -1,7 +1,7 @@ /* 100% Elimination of PeerTube Mobile Open-in-App & Incompatible Browser Banners */ #incompatible-browser, .alert-light#incompatible-browser, -div[id="incompatible-browser"], +div[id='incompatible-browser'], .incompatible-browser, .mobile-msg, my-header .mobile-msg, @@ -947,7 +947,6 @@ body.yaktube-theater-mode .video-js { 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,