import { initTelemetry } from '/profile/telemetry.js'; initTelemetry().catch(() => {}); async function refreshProfile() { try { const response = await fetch('/api/profile', {cache:'no-store'}); if (!response.ok) { document.body.replaceChildren(); location.replace('/'); return; } const personal = await response.json(); if (personal.username !== window.TPTProfile.username) { document.body.replaceChildren(); location.replace('/'); return; } window.TPTProfile = personal; window.applyPrivateProfile(); window.render(); } catch { /* Keep the current view during a temporary connection failure. */ } } addEventListener('focus',refreshProfile); addEventListener('pageshow',event => {if(event.persisted) refreshProfile();}); document.addEventListener('visibilitychange',()=>{if(!document.hidden) refreshProfile();});