From 38bbd13c7fe55026ed85173ad69cca92d21481a7 Mon Sep 17 00:00:00 2001 From: user Date: Fri, 27 Feb 2026 02:00:01 -0800 Subject: [PATCH] fix: show 'not available on mobile' message instead of broken layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detect mobile devices via user agent and viewport width (<=768px). On mobile, skip all checker initialization and render only the header, description, and a styled 'Not yet available on mobile' box. Desktop behavior is completely unchanged — the mobile check returns early before any existing code runs. --- src/main.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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]; -- 2.49.1