From 19363f6cb9fef7877d0a14870fc6a58f8723686c Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sun, 15 Oct 2023 16:08:19 +0300 Subject: [PATCH] Move variables extension to external repo --- public/scripts/extensions/variables/index.js | 66 ------------------- .../extensions/variables/manifest.json | 11 ---- 2 files changed, 77 deletions(-) delete mode 100644 public/scripts/extensions/variables/index.js delete mode 100644 public/scripts/extensions/variables/manifest.json diff --git a/public/scripts/extensions/variables/index.js b/public/scripts/extensions/variables/index.js deleted file mode 100644 index 478181b7d..000000000 --- a/public/scripts/extensions/variables/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import { getContext } from "../../extensions.js"; - -/** - * Gets a chat variable from the current chat metadata. - * @param {string} name The name of the variable to get. - * @returns {string} The value of the variable. - */ -function getChatVariable(name) { - const metadata = getContext().chatMetadata; - - if (!metadata) { - return ''; - } - - if (!metadata.variables) { - metadata.variables = {}; - return ''; - } - - return metadata.variables[name] || ''; -} - -/** - * Sets a chat variable in the current chat metadata. - * @param {string} name The name of the variable to set. - * @param {any} value The value of the variable to set. - */ -function setChatVariable(name, value) { - if (name === undefined || value === undefined) { - return; - } - - const metadata = getContext().chatMetadata; - - if (!metadata) { - return; - } - - if (!metadata.variables) { - metadata.variables = {}; - } - - metadata.variables[name] = value; -} - -function listChatVariables() { - const metadata = getContext().chatMetadata; - - if (!metadata) { - return ''; - } - - if (!metadata.variables) { - metadata.variables = {}; - return ''; - } - - return Object.keys(metadata.variables).map(key => `${key}=${metadata.variables[key]}`).join(';'); -} - -jQuery(() => { - const context = getContext(); - context.registerHelper('getvar', getChatVariable); - context.registerHelper('setvar', setChatVariable); - context.registerHelper('listvar', listChatVariables); -}); diff --git a/public/scripts/extensions/variables/manifest.json b/public/scripts/extensions/variables/manifest.json deleted file mode 100644 index 9c4e9cc48..000000000 --- a/public/scripts/extensions/variables/manifest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "display_name": "Chat Variables", - "loading_order": 100, - "requires": [], - "optional": [], - "js": "index.js", - "css": "", - "author": "Cohee#1207", - "version": "1.0.0", - "homePage": "https://github.com/SillyTavern/SillyTavern" -}