From 22974f5d86bb6a7fd8d4b7a76be0655648cb05a0 Mon Sep 17 00:00:00 2001 From: An Orbit <68935009+orbit-loona@users.noreply.github.com> Date: Fri, 21 Jun 2024 18:38:31 -0400 Subject: [PATCH] bugfix attempt (different behavior on local copy vs online) --- mods/a_mod_by_alice.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/a_mod_by_alice.js b/mods/a_mod_by_alice.js index 1b4be2ea..2a091c29 100644 --- a/mods/a_mod_by_alice.js +++ b/mods/a_mod_by_alice.js @@ -8,8 +8,8 @@ try { //COMMON VARIABLES ## const whiteColor = {r: 255, g: 255, b: 255}; const blackColor = {r: 0, g: 0, b: 0}; - canvas = document.getElementsByTagName("canvas")[0]; - ctx = canvas.getContext("2d"); + canvas = document.getElementsByTagName("canvas")?.[0]; + ctx = canvas?.getContext?.("2d") ?? null; //ESSENTIAL COMMON FUNCTIONS (CODE LIBRARY) ## //DEBUGGING function logAndReturn(thing) { @@ -3471,6 +3471,10 @@ color1 and color2 spread through striped paint like dye does with itself. col focusGame(); }; window.onload = function() { + if(canvas == null || ctx == null) { + canvas = document.getElementsByTagName("canvas")[0]; + ctx = canvas.getContext("2d") ?? null; + } // If the browser is Firefox, set #categoryControls padding-bottom:11px; if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.getElementById("categoryControls").style.paddingBottom = "11px";