diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js index df4b7022f..181ec9b1c 100644 --- a/public/scripts/extensions.js +++ b/public/scripts/extensions.js @@ -1,4 +1,4 @@ -import { callPopup, saveSettings, saveSettingsDebounced } from "../script.js"; +import { callPopup, saveSettings, saveSettingsDebounced, token } from "../script.js"; import { isSubsetOf } from "./utils.js"; export { getContext, @@ -9,8 +9,8 @@ export { extension_settings, }; -const extensionNames = ['caption', 'dice', 'expressions', 'floating-prompt', 'memory', 'backgrounds']; -const manifests = await getManifests(extensionNames); +let extensionNames = []; +let manifests = []; const defaultUrl = "http://localhost:5100"; const extension_settings = { @@ -34,6 +34,24 @@ const getApiUrl = () => extension_settings.apiUrl; const defaultRequestArgs = { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } }; let connectedToApi = false; +async function discoverExtensions() { + try { + const response = await fetch('/discover_extensions', { headers: { 'X-CSRF-Token': token } }); + + if (response.ok) { + const extensions = await response.json(); + return extensions; + } + else { + return []; + } + } + catch (err) { + console.error(err); + return []; + } +} + function onDisableExtensionClick() { const name = $(this).data('name'); disableExtension(name); @@ -247,7 +265,7 @@ function showExtensionsDetails() { callPopup(`