Fix login link — open via window.open with popup-blocker fallback, preventDefault on anchor

This commit is contained in:
Kato
2026-09-05 21:25:30 +00:00
parent 42c0d6853a
commit 2ff10df90c
+10 -2
View File
@@ -97,8 +97,16 @@ document.addEventListener('DOMContentLoaded', () => {
// Login button — opens Telegram bot deep-link, then locks itself // Login button — opens Telegram bot deep-link, then locks itself
const loginBtn = document.getElementById('login-btn'); const loginBtn = document.getElementById('login-btn');
if (loginBtn) { if (loginBtn) {
loginBtn.addEventListener('click', () => { loginBtn.addEventListener('click', (e) => {
// No modal: swap label, drop the link, make the button unclickable e.preventDefault();
const url = loginBtn.href;
// Open the link programmatically (reliable than relying on href after DOM changes)
const w = window.open(url, '_blank');
if (!w || w.closed) {
// Popup blocked — fallback: navigate same window
window.location.href = url;
}
// Then swap label and lock
loginBtn.innerHTML = 'Approve in Telegram'; loginBtn.innerHTML = 'Approve in Telegram';
loginBtn.removeAttribute('href'); loginBtn.removeAttribute('href');
loginBtn.classList.add('btn-locked'); loginBtn.classList.add('btn-locked');