(function() { const userAgent = navigator.userAgent || navigator.vendor || window.opera; // Detect In-App Browsers: Instagram, Facebook, TikTok, and Twitter if (userAgent.includes("FBAN") || userAgent.includes("FBAV") || userAgent.includes("Instagram") || userAgent.includes("TikTok") || userAgent.includes("Twitter")) { // Attempt to open in the default browser using custom URL schemes (Chrome as an example) const externalLink = window.location.href; // For Chrome on Android if (/Android/i.test(userAgent)) { window.location.href = "intent://" + externalLink.replace(/^https?:\/\//, "") + "#Intent;scheme=https;package=com.android.chrome;end;"; } // For iOS (Safari) else if (/iPhone|iPad|iPod/i.test(userAgent)) { window.location.href = "https://" + window.location.hostname + window.location.pathname; setTimeout(() => { window.location.href = externalLink; }, 1000); } // Fallback for other environments else { window.location.href = externalLink; } } })();