mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-20 02:29:31 -07:00
Merge pull request #95 from kirbysayshi/ksh/disable-radar-for-bots
Expand radar feature disabling to cover all iOS browsers and the Messages crawler
This commit is contained in:
@@ -6,15 +6,27 @@ import WeatherDisplay from './weatherdisplay.mjs';
|
|||||||
import { registerDisplay, timeZone } from './navigation.mjs';
|
import { registerDisplay, timeZone } from './navigation.mjs';
|
||||||
import * as utils from './radar-utils.mjs';
|
import * as utils from './radar-utils.mjs';
|
||||||
|
|
||||||
// TEMPORARY fix to disable radar on ios safari
|
// TEMPORARY fix to disable radar on ios safari. The same engine (webkit) is
|
||||||
|
// used for all ios browers (chrome, brave, firefox, etc) so it's safe to skip
|
||||||
|
// any subsequent narrowing of the user-agent.
|
||||||
const isIos = /iP(ad|od|hone)/i.test(window.navigator.userAgent);
|
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
|
||||||
const safariIos = isIos && isSafari;
|
// 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 RADAR_HOST = 'mesonet.agron.iastate.edu';
|
const RADAR_HOST = 'mesonet.agron.iastate.edu';
|
||||||
class Radar extends WeatherDisplay {
|
class Radar extends WeatherDisplay {
|
||||||
constructor(navId, elemId) {
|
constructor(navId, elemId) {
|
||||||
super(navId, elemId, 'Local Radar', !safariIos);
|
super(navId, elemId, 'Local Radar', !isIos && !isBot);
|
||||||
|
|
||||||
this.okToDrawCurrentConditions = false;
|
this.okToDrawCurrentConditions = false;
|
||||||
this.okToDrawCurrentDateTime = false;
|
this.okToDrawCurrentDateTime = false;
|
||||||
@@ -207,7 +219,7 @@ const radarWorker = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// register display
|
// register display
|
||||||
// TEMPORARY: except on safari on IOS
|
// TEMPORARY: except on IOS and bots
|
||||||
if (!safariIos) {
|
if (!isIos && !isBot) {
|
||||||
registerDisplay(new Radar(11, 'radar'));
|
registerDisplay(new Radar(11, 'radar'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user