From 540d93592b46df0a3e8759610affcdf9d9591f10 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 24 Dec 2024 22:15:33 +0200 Subject: [PATCH] Add fallback mechanism for background selection in autoBackgroundCommand --- public/scripts/backgrounds.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/scripts/backgrounds.js b/public/scripts/backgrounds.js index 7b25728ef..8d521094b 100644 --- a/public/scripts/backgrounds.js +++ b/public/scripts/backgrounds.js @@ -333,6 +333,14 @@ async function autoBackgroundCommand() { const bestMatch = fuse.search(reply, { limit: 1 }); if (bestMatch.length == 0) { + for (const option of options) { + if (String(reply).toLowerCase().includes(option.text.toLowerCase())) { + console.debug('Fallback choosing background:', option); + option.element.click(); + return ''; + } + } + toastr.warning('No match found. Please try again.'); return ''; }