// In-Telegram polish for every site page. No-ops in a normal browser; inside // the Mini App webview it lazy-loads the vendored Telegram SDK (CSP stays // script-src 'self') and wires theme + BackButton so pages feel native. (function () { 'use strict'; var inTg = false; try { inTg = sessionStorage.getItem('rmcTg') === '1'; } catch (e) {} if (!inTg && (window.TelegramWebviewProxy !== undefined || /tgWebApp(Data|Platform)/.test(location.hash))) inTg = true; if (!inTg) return; try { sessionStorage.setItem('rmcTg', '1'); } catch (e) {} function boot() { var tg = window.Telegram && window.Telegram.WebApp; if (!tg || !tg.initData) return; tg.ready(); try { tg.expand(); } catch (e) {} try { tg.setHeaderColor('#071421'); tg.setBackgroundColor('#071421'); } catch (e) {} // Back button mirrors webview history: /app enters via location.replace, so // the landing dashboard has no history and stays clean; any deeper page // (tools, training, another member view) gets a native back arrow. var bb = tg.BackButton; if (bb && history.length > 1) { bb.show(); bb.onClick(function () { history.back(); }); } } if (window.Telegram && window.Telegram.WebApp) { boot(); return; } var s = document.createElement('script'); s.src = '/telegram-web-app.js'; s.onload = boot; document.head.appendChild(s); })();