shithub: puzzles

Download patch

ref: c0f715fbaca77fbb6e86de604098d82687bdea48
parent: 5a74693b329eadb69153b150754eb099a0c87e9a
author: Ben Harris <bjh21@bjh21.me.uk>
date: Wed Mar 1 17:13:59 EST 2023

KaiOS: be more cautious about determining whether KaiAds is present

Just checking for the getKaiAd() function by doing "if (!getKaiAd ..."
throws a ReferenceError if it's not defined, and now my error box
catches that.  Using "if (getKaiAd === undefined ..." seems to be
acceptable, though.

--- a/kaios/kaiads-glue.js
+++ b/kaios/kaiads-glue.js
@@ -11,7 +11,7 @@
 (function() {
     // To run, we need to be on KaiOS with the KaiAds SDK and the
     // Open Web Apps API.
-    if (!getKaiAd || !navigator.mozApps ||
+    if (getKaiAd === undefined || navigator.mozApps === undefined ||
         navigator.userAgent.toLowerCase().indexOf('kaios') == -1) return;
     // If those prerequisites are satisfied, install the button.
     var advertbutton = document.createElement("button");