From 2365a4c0f74243f266f37b19f19752ad7596305b Mon Sep 17 00:00:00 2001 From: Andrew Petersen Date: Sun, 1 Jun 2025 17:05:18 -0400 Subject: [PATCH] prevent loading radar for iMessages web preview bot --- server/scripts/modules/radar.mjs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/scripts/modules/radar.mjs b/server/scripts/modules/radar.mjs index 265f9d4..3ad5f5d 100644 --- a/server/scripts/modules/radar.mjs +++ b/server/scripts/modules/radar.mjs @@ -9,12 +9,24 @@ import * as utils from './radar-utils.mjs'; // TEMPORARY fix to disable radar on ios safari const isIos = /iP(ad|od|hone)/i.test(window.navigator.userAgent); const isSafari = !!navigator.userAgent.match(/Version\/[\d.]+.*Safari/); +// NOTE: iMessages/Messages preview is provided by an Apple scraper that uses a +// user-agent similar to: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) +// AppleWebKit/601.2.4 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.4 +// facebookexternalhit/1.1 Facebot Twitterbot/1.0`. There is currently a bug in +// Messages macos/ios where a constantly crashing website seems to cause an +// entire Messages thread to permanently lockup until the individual website +// preview is deleted! Messages ios will judder but allows the message to be +// deleted eventually. Messages macos beachballs forever and prevents the +// successful deletion. See +// https://github.com/netbymatt/ws4kp/issues/74#issuecomment-2921154962 for more +// context. +const isBot = /twitterbot|Facebot/i.test(window.navigator.userAgent); const safariIos = isIos && isSafari; const RADAR_HOST = 'mesonet.agron.iastate.edu'; class Radar extends WeatherDisplay { constructor(navId, elemId) { - super(navId, elemId, 'Local Radar', !safariIos); + super(navId, elemId, 'Local Radar', !safariIos && !isBot); this.okToDrawCurrentConditions = false; this.okToDrawCurrentDateTime = false; @@ -207,7 +219,7 @@ const radarWorker = () => { }; // register display -// TEMPORARY: except on safari on IOS -if (!safariIos) { +// TEMPORARY: except on safari on IOS and bots +if (!safariIos && !isBot) { registerDisplay(new Radar(11, 'radar')); }