diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index 653473e..859d0be 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -254,6 +254,9 @@ function hideResults(textArea) { // Function to check activation criteria function isEnabled() { if (CFG.activeIn.global) { + // Skip check if the current model was not correctly detected, since it could wrongly disable the script otherwise + if (!currentModelName || !currentModelHash) return true; + let modelList = CFG.activeIn.modelList .split(",") .map(x => x.trim()) @@ -822,8 +825,14 @@ async function setup() { for (const mutation of mutationList) { if (mutation.type === "attributes" && mutation.attributeName === "title") { currentModelHash = mutation.target.title; - let modelDropdown = gradioApp().querySelector("#setting_sd_model_checkpoint span.single-select"); - currentModelName = modelDropdown?.textContent; + let modelDropdown = gradioApp().querySelector("#setting_sd_model_checkpoint span.single-select") + if (modelDropdown) { + currentModelName = modelDropdown.textContent; + } else { + // Fallback for older versions + modelDropdown = gradioApp().querySelector("#setting_sd_model_checkpoint select"); + currentModelName = modelDropdown.value; + } } } });