document.addEventListener('DOMContentLoaded', function() { const currentUser = JSON.parse(localStorage.getItem('currentUser')); const loginLink = document.getElementById('login-link'); const registerLink = document.getElementById('register-link'); const profileLink = document.getElementById('profile-link'); const logoutLink = document.getElementById('logout-link'); if (currentUser) { loginLink.style.display = 'none'; registerLink.style.display = 'none'; profileLink.style.display = 'block'; logoutLink.style.display = 'block'; } else { loginLink.style.display = 'block'; registerLink.style.display = 'block'; profileLink.style.display = 'none'; logoutLink.style.display = 'none'; } logoutLink.addEventListener('click', function(event) { event.preventDefault(); localStorage.removeItem('currentUser'); loginLink.style.display = 'block'; registerLink.style.display = 'block'; profileLink.style.display = 'none'; logoutLink.style.display = 'none'; }); });