From 5ba1bf55600443ca6cdad448aa629ffbce7c4e22 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 11 Dec 2022 12:17:54 +0000 Subject: js: Tolerate the absence of various UI elements from the HTML To make things more consistent, the static buttons now all have their own variables. --- emcclib.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'emcclib.js') diff --git a/emcclib.js b/emcclib.js index 676c429..07cbf3b 100644 --- a/emcclib.js +++ b/emcclib.js @@ -62,9 +62,11 @@ mergeInto(LibraryManager.library, { * provides neither presets nor configurability. */ js_remove_type_dropdown: function() { + if (gametypelist === null) return; var gametypeitem = gametypelist.closest("li"); if (gametypeitem === null) return; gametypeitem.parentNode.removeChild(gametypeitem); + gametypelist = null; }, /* @@ -74,11 +76,11 @@ mergeInto(LibraryManager.library, { * time if the game doesn't support an in-game solve function. */ js_remove_solve_button: function() { - var solvebutton = document.getElementById("solve"); - if (solvebutton === null) return; - var solveitem = solvebutton.closest("li"); - if (solveitem === null) return; - solveitem.parentNode.removeChild(solveitem); + if (solve_button === null) return; + var solve_item = solve_button.closest("li"); + if (solve_item === null) return; + solve_item.parentNode.removeChild(solve_item); + solve_button = null; }, /* -- cgit v1.1