const wrapper = document.querySelector('.envoltoria'); const btnPopupDesktop = document.querySelector('.btnLogin-popup'); const btnPopupMobile = document.querySelector('.btnLogin-popup-mobile'); const iconClose = document.querySelector('.icone-fechar'); // Se o usuário estiver logado, redireciona ao clicar no botão if (btnPopupDesktop) { btnPopupDesktop.addEventListener('click', () => { wrapper.classList.add('active-popup'); // abre modal }); } if (btnPopupMobile) { btnPopupMobile.addEventListener('click', () => { window.location.href = "login.html"; // redireciona }); } iconClose.addEventListener('click', () => { wrapper.classList.remove('active-popup'); }); window.addEventListener('DOMContentLoaded', () => { const params = new URLSearchParams(window.location.search); const abrirLogin = params.get('login'); if (abrirLogin === 'abrir') { const wrapper = document.querySelector('.envoltoria'); const btnPopup = document.querySelector('.btnLogin-popup'); if (btnPopup && wrapper) { btnPopup.click(); // simula o clique (vai abrir ou redirecionar) } const novaURL = window.location.origin + window.location.pathname; window.history.replaceState({}, document.title, novaURL); } });