diff --git a/wwwroot/app.js b/wwwroot/app.js index 1231e83..6f76397 100644 --- a/wwwroot/app.js +++ b/wwwroot/app.js @@ -34,9 +34,20 @@ function setAuthUI(isAuthed) { if (!isAuthed) { const adminCard = $("admin-card"); if (adminCard) adminCard.classList.add("hidden"); + const loginUser = $("login-username"); + const cachedUser = getCookie("player_username"); + if (loginUser && cachedUser) loginUser.value = cachedUser; } } +function getCookie(name) { + const cookie = document.cookie + ?.split(";") + .map(c => c.trim()) + .find(c => c.startsWith(name + "=")); + return cookie ? decodeURIComponent(cookie.split("=").slice(1).join("=")) : null; +} + function setAuthMode(mode) { state.authMode = mode; document.querySelectorAll(".auth-form").forEach(form => {