This works:
if (window.TelegramWebview) { const url = window.location.href; const chromeUrl = `intent://${url.replace(/^https?:\/\//, '')}#Intent;scheme=https;end`; window.location.href = chromeUrl; }