diff --git a/src/main.js b/src/main.js index 3ab6bb8..b99a827 100644 --- a/src/main.js +++ b/src/main.js @@ -1128,9 +1128,42 @@ function handleResize(state) { // --- Bootstrap --------------------------------------------------------------- +// --- Mobile Detection -------------------------------------------------------- + +function isMobile() { + // Check both user agent and viewport width for robust detection + const uaMatch = + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( + navigator.userAgent, + ); + const narrowViewport = window.innerWidth <= 768; + return uaMatch || narrowViewport; +} + +function buildMobileUI() { + const app = document.getElementById("app"); + app.innerHTML = ` +
+
+

NetWatch by @sneak

+

Real-time network latency monitor

+
+
+

Not yet available on mobile.

+

Please visit on a desktop browser for the full experience.

+
+
`; +} + async function init() { log.info("NetWatch starting"); + if (isMobile()) { + log.info("Mobile device detected — showing placeholder"); + buildMobileUI(); + return; + } + // Probe common gateway IPs to find the local router const gateway = await detectGateway(); const localHosts = [LOCAL_CPE];