From 44302463abb65c2bc1bb0ebed9ad5835b5c63a85 Mon Sep 17 00:00:00 2001 From: niemes Date: Tue, 14 May 2024 21:09:56 +0000 Subject: [PATCH] Avoid useless custom functions on login screen --- custom_portal.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/custom_portal.js b/custom_portal.js index 78b6e5b..a51d45a 100644 --- a/custom_portal.js +++ b/custom_portal.js @@ -102,23 +102,25 @@ init_portal = async function() init_portal_original(); // Don't wait if logged - if (document.body.className.indexOf("logged") == -1) document.body.style.opacity = 1.0; - - window.openApp = (link) => window.open(link, "_blank"); - if (config.customIcons) await addAppsLogo() - if (config.customAvatars) await useCustomAvatar() - - // links - let footerNav = 'div.ynh-wrapper:nth-child(3) > nav:nth-child(1)' - var target = document.getElementsByClassName('user')[0]; - target.id = "user" - - let mainNav = document.querySelector(footerNav) - let clonedMenu = mainNav.cloneNode(true); - clonedMenu.id = "mainmenu" - - target.appendChild(clonedMenu); - mainNav.remove() + if (document.body.className.indexOf("logged") == -1) { + document.body.style.opacity = 1.0; + } else { // handle custom UI only if logged + window.openApp = (link) => window.open(link, "_blank"); + if (config.customIcons) await addAppsLogo() + if (config.customAvatars) await useCustomAvatar() + + // links menu + let footerNav = 'div.ynh-wrapper:nth-child(3) > nav:nth-child(1)' + var target = document.getElementsByClassName('user')[0]; + target.id = "user" + + let mainNav = document.querySelector(footerNav) + let clonedMenu = mainNav.cloneNode(true); + clonedMenu.id = "mainmenu" + + target.appendChild(clonedMenu); + mainNav.remove() + } document.body.style.opacity = 1.0; }