aboutsummaryrefslogtreecommitdiff
path: root/kaios
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-03-22 22:54:08 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-03-22 22:54:19 +0000
commit255744676c0c4c8fa391d7a03bdd3142d6db0ad2 (patch)
treed77c0fb638f3f0387a887558cabec4fbc2a25c76 /kaios
parentb66a38bbdc4405cce7050b8e8bbcae8d69c3dc2c (diff)
downloadpuzzles-255744676c0c4c8fa391d7a03bdd3142d6db0ad2.zip
puzzles-255744676c0c4c8fa391d7a03bdd3142d6db0ad2.tar.gz
puzzles-255744676c0c4c8fa391d7a03bdd3142d6db0ad2.tar.bz2
puzzles-255744676c0c4c8fa391d7a03bdd3142d6db0ad2.tar.xz
KaiOS: be more careful detecting the presence of KaiAds
Now that we catch JavaScript errors and report them to the user, I could tell that the way we were detecting the presence of getKaiAd() didn't work because it caused an alert every time a build without KaiAds was started. Detecting the presence of a global variable is slightly tricky, but explicitly looking for it on "window" works and isn't very ugly.
Diffstat (limited to 'kaios')
-rw-r--r--kaios/kaiads-glue.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaios/kaiads-glue.js b/kaios/kaiads-glue.js
index 62634b2..2f7788b 100644
--- 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 === undefined || navigator.mozApps === undefined ||
+ if (window.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");