From fcfb9c665ee648b9a2e83db9645d353bc1daffbc Mon Sep 17 00:00:00 2001 From: somebody Date: Sun, 16 Oct 2022 10:39:25 -0500 Subject: [PATCH] Fix Chrome onload --- static/koboldai.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/static/koboldai.js b/static/koboldai.js index a8c81f1a..144aed7e 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -2670,8 +2670,18 @@ function calc_token_usage( } function Change_Theme(theme) { - var css = document.getElementById("CSSTheme"); - css.setAttribute("href", "/themes/"+theme+".css"); + const oldCSS = $el("#CSSTheme"); + if (oldCSS) oldCSS.remove(); + + const css = $e( + "link", + document.head, + { + id: "CSSTheme", + rel: "stylesheet", + href: `/themes/${theme}.css` + } + ); // We must wait for the style to load before we read it css.onload = function() {