From d1a9332fc403bb4158ab25cd99c72326a2684f70 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 24 Aug 2022 14:30:27 +0200 Subject: [PATCH] Update ChatAliases.plugin.js --- Plugins/ChatAliases/ChatAliases.plugin.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Plugins/ChatAliases/ChatAliases.plugin.js b/Plugins/ChatAliases/ChatAliases.plugin.js index 8135bf090f..5e08f409c9 100644 --- a/Plugins/ChatAliases/ChatAliases.plugin.js +++ b/Plugins/ChatAliases/ChatAliases.plugin.js @@ -2,7 +2,7 @@ * @name ChatAliases * @author DevilBro * @authorId 278543574059057154 - * @version 2.4.2 + * @version 2.4.3 * @description Allows you to configure your own Aliases/Commands * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,7 +17,7 @@ module.exports = (_ => { "info": { "name": "ChatAliases", "author": "DevilBro", - "version": "2.4.2", + "version": "2.4.3", "description": "Allows you to configure your own Aliases/Commands" } }; @@ -177,7 +177,12 @@ module.exports = (_ => { onSelect: data => { if (data.results.aliases[data.index].word.indexOf(" ") > -1) { let textValue = BDFDB.ReactUtils.findValue(BDFDB.DOMUtils.getParent(BDFDB.dotCN.textareawrapall, document.activeElement) || document.querySelector(BDFDB.dotCN.textareawrapall), "textValue"); - if (textValue) data.options.replaceText(textValue.replace(new RegExp(BDFDB.StringUtils.regEscape(data.results.aliases[data.index].word), data.results.aliases[data.index].case ? "gi" : "g"), BDFDB.StringUtils.insertNRST(data.results.aliases[data.index].replace))); + if (textValue) { + let replace = BDFDB.StringUtils.insertNRST(data.results.aliases[data.index].replace); + let escapedQuery = BDFDB.StringUtils.regEscape(query); + let config = data.results.aliases[data.index].case ? "gi" : "g"; + data.options.replaceText(textValue.replace(new RegExp(`(\\s)${escapedQuery}(\\s)`, config), `$1${replace}$2`).replace(new RegExp(`^${escapedQuery}(\\s)`, config), `${replace}$1`).replace(new RegExp(`(\\s)${escapedQuery}$`, config), `$1${replace}`)); + } } else data.options.insertText(BDFDB.StringUtils.insertNRST(data.results.aliases[data.index].replace)); return {};