Untitled
unknown
plain_text
2 months ago
1.5 kB
2
Indexable
(function () { function isInstagramWebView() { let ua = navigator.userAgent || navigator.vendor || window.opera; return ua.includes("Instagram"); } function redirectToNativeBrowser() { let url = window.location.href; // For Android: Use intent:// to force open in Chrome if (/android/i.test(navigator.userAgent)) { window.location.href = `intent://${url.replace(/^https?:\/\//, '')}#Intent;scheme=https;package=com.android.chrome;end;`; } // For iOS: Try opening in Chrome first, fallback to Safari else if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { let chromeUrl = "googlechrome://" + url.replace(/^https?:\/\//, ''); let newTab = window.open(chromeUrl, "_blank"); // If Chrome is not installed, fallback to Safari setTimeout(() => { if (!newTab || newTab.closed) { window.location.href = url; } }, 500); } } function showRedirectConfirmation() { if (confirm("You are viewing this page in Instagram's browser. For a better experience, we recommend opening it in your native browser. Would you like to proceed?")) { redirectToNativeBrowser(); } } // Run only if inside Instagram WebView if (isInstagramWebView()) { setTimeout(showRedirectConfirmation, 1000); // Delay for better execution } })();
Editor is loading...
Leave a Comment