diff --git a/Plugins/ChatAliases/ChatAliases.plugin.js b/Plugins/ChatAliases/ChatAliases.plugin.js index 32a7f9e664..a426fdb3b9 100644 --- a/Plugins/ChatAliases/ChatAliases.plugin.js +++ b/Plugins/ChatAliases/ChatAliases.plugin.js @@ -3,7 +3,7 @@ class ChatAliases { getName () {return "ChatAliases";} - getVersion () {return "1.9.7";} + getVersion () {return "1.9.8";} getAuthor () {return "DevilBro";} @@ -11,7 +11,7 @@ class ChatAliases { initConstructor () { this.changelog = { - "added":[["ContextMenu","Added an contextmenu entry when right clicking a highlighted/selected word to allow you to faster add new aliases"]] + "improved":[["Min Length","Plugin now allows you to set a minimum character length required for the Autocomplete-Menu to show up to avoid the Autocomplete-Menu from opening on words like 'i' and 'a' in case an aliases starts with these letters, which could have prevented you from sending the message via enter before"]] }; this.patchModules = { @@ -30,6 +30,9 @@ class ChatAliases { settings: { addContextMenu: {value:true, description:"Add a ContextMenu entry to faster add new Aliases:"}, addAutoComplete: {value:true, description:"Add an Autocomplete-Menu for Non-Regex Aliases:"} + }, + amounts: { + minAliasLength: {value:2, min:1, description:"Minimal Character Length to open Autocomplete-Menu:"} } }; @@ -99,10 +102,14 @@ class ChatAliases { getSettingsPanel () { if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; var settings = BDFDB.getAllData(this, "settings"); + var amounts = BDFDB.getAllData(this, "amounts"); var settingshtml = `
${this.name}
`; for (let key in settings) { settingshtml += `

${this.defaults.settings[key].description}

`; } + for (let key in amounts) { + settingshtml += `

${this.defaults.amounts[key].description}

`; + } settingshtml += `

Replace:

With:

`; settingshtml += `

List of Chataliases:

`; for (let config in this.defaults.configs) { @@ -161,8 +168,6 @@ class ChatAliases { BDFDB.loadMessage(this); this.UploadModule = BDFDB.WebModules.findByProperties("instantBatchUpload"); - this.CurrentUserPerms = BDFDB.WebModules.findByProperties("getChannelPermissions", "can"); - this.Permissions = BDFDB.WebModules.findByProperties("Permissions", "ActivityTypes").Permissions; this.aliases = BDFDB.loadAllData(this, "words"); @@ -188,7 +193,9 @@ class ChatAliases { // begin of own functions updateContainer (settingspanel, ele) { - var action = ele.getAttribute("action"), update = () => { + var wordvalue = null, replacevalue = null, action = ele.getAttribute("action"); + + var update = () => { BDFDB.saveAllData(this.aliases, this, "words"); var containerhtml = ``; @@ -214,7 +221,7 @@ class ChatAliases { } } else if (action == "remove") { - var wordvalue = ele.getAttribute("word"); + wordvalue = ele.getAttribute("word"); if (wordvalue) { delete this.aliases[wordvalue]; update(); @@ -327,11 +334,9 @@ class ChatAliases { } processChannelTextArea (instance, wrapper) { - if (instance.props && instance.props.type) { + if (instance.props && instance.props.channel && instance.props.type) { var textarea = wrapper.querySelector("textarea"); if (!textarea) return; - var channel = BDFDB.getSelectedChannel(); - if (!channel) return; var settings = BDFDB.getAllData(this, "settings"); BDFDB.addEventListener(this, textarea, "input", () => { if (this.format) { @@ -344,8 +349,8 @@ class ChatAliases { if (messageInput && messageInput.text != null) { document.execCommand("insertText", false, messageInput.text ? messageInput.text + " " : ""); } - if (messageInput && messageInput.files.length > 0 && (channel.type == 1 || this.CurrentUserPerms.can(this.Permissions.ATTACH_FILES, channel))) { - this.UploadModule.instantBatchUpload(channel.id, messageInput.files); + if (messageInput && messageInput.files.length > 0 && (instance.props.channel.type == 1 || BDFDB.isUserAllowedTo("ATTACH_FILES"))) { + this.UploadModule.instantBatchUpload(instance.props.channel.id, messageInput.files); } } } @@ -387,7 +392,7 @@ class ChatAliases { } addAutoCompleteMenu (textarea) { - if (textarea.parentElement.querySelector(".autocompleteAliasesRow")) return; + if (!textarea.value || textarea.parentElement.querySelector(".autocompleteAliasesRow") || BDFDB.getData("minAliasLength", this, "amounts") > textarea.value.length) return; let words = textarea.value.split(/\s/); let lastword = words[words.length-1].trim(); if (words.length == 1 && BDFDB.isPluginEnabled("WriteUpperCase")) { diff --git a/Plugins/EmojiStatistics/EmojiStatistics.plugin.js b/Plugins/EmojiStatistics/EmojiStatistics.plugin.js index f50f13bf7e..1635dc7f4e 100644 --- a/Plugins/EmojiStatistics/EmojiStatistics.plugin.js +++ b/Plugins/EmojiStatistics/EmojiStatistics.plugin.js @@ -158,7 +158,7 @@ class EmojiStatistics { enableEmojiStatisticsButton: {value:true, description:"Add a Button in the Emojipicker to open the Statistics Overview."} }, amounts: { - hoverDelay: {value:1000, description:"Tooltip delay in millisec:"} + hoverDelay: {value:1000, min:0, description:"Tooltip delay in millisec:"} } }; } @@ -172,7 +172,7 @@ class EmojiStatistics { settingshtml += `

${this.defaults.settings[key].description}

`; } for (let key in amounts) { - settingshtml += `

${this.defaults.amounts[key].description}

`; + settingshtml += `

${this.defaults.amounts[key].description}

`; } settingshtml += `
`; @@ -180,11 +180,6 @@ class EmojiStatistics { BDFDB.initElements(settingspanel, this); - BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => { - var input = parseInt(e.currentTarget.value); - if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts"); - }); - return settingspanel; } diff --git a/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js b/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js index 5adc419f83..38b2474015 100644 --- a/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js +++ b/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js @@ -90,7 +90,7 @@ class ShowHiddenChannels { showTopic: {value:false, description:"Show the topic of hidden channels:"} }, amounts: { - hoverDelay: {value:0, description:"Tooltip delay in millisec:"} + hoverDelay: {value:0, min:0, description:"Tooltip delay in millisec:"} } }; } @@ -104,7 +104,7 @@ class ShowHiddenChannels { settingshtml += `

${this.defaults.settings[key].description}

`; } for (let key in amounts) { - settingshtml += `

${this.defaults.amounts[key].description}

`; + settingshtml += `

${this.defaults.amounts[key].description}

`; } settingshtml += `
`; @@ -112,11 +112,6 @@ class ShowHiddenChannels { BDFDB.initElements(settingspanel, this); - BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => { - var input = parseInt(e.currentTarget.value); - if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts"); - }); - return settingspanel; } @@ -379,8 +374,7 @@ class ShowHiddenChannels { } createHiddenObjContextMenu (guild, channel, type, e) { - e.preventDefault(); - e.stopPropagation(); + BDFDB.stopEvent(e); var contextMenu = BDFDB.htmlToElement(`
${BDFDB.isPluginEnabled("PermissionsViewer") ? '
' : ''}
${BDFDB.LanguageStrings.COPY_ID}
`); var reactInstance = BDFDB.React.createElement(contextMenu); reactInstance.memoizedProps = {displayName:"ChannelDeleteGroup",guild,channel}; diff --git a/Plugins/ShowImageDetails/ShowImageDetails.plugin.js b/Plugins/ShowImageDetails/ShowImageDetails.plugin.js index e6b2c81c4d..9cead40a30 100644 --- a/Plugins/ShowImageDetails/ShowImageDetails.plugin.js +++ b/Plugins/ShowImageDetails/ShowImageDetails.plugin.js @@ -36,7 +36,7 @@ class ShowImageDetails { showOnHover: {value:false, description:"Show the details as Tooltip instead:"} }, amounts: { - hoverDelay: {value:0, description:"Tooltip delay in millisec:"} + hoverDelay: {value:0, min:0, description:"Tooltip delay in millisec:"} } }; } @@ -50,7 +50,7 @@ class ShowImageDetails { settingshtml += `

${this.defaults.settings[key].description}

`; } for (let key in amounts) { - settingshtml += `

${this.defaults.amounts[key].description}

`; + settingshtml += `

${this.defaults.amounts[key].description}

`; } settingshtml += ``; @@ -58,11 +58,6 @@ class ShowImageDetails { BDFDB.initElements(settingspanel, this); - BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => { - let input = parseInt(e.currentTarget.value); - if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts"); - }); - return settingspanel; } diff --git a/Plugins/SpellCheck/SpellCheck.plugin.js b/Plugins/SpellCheck/SpellCheck.plugin.js index 3868ece26f..b7da0ff594 100644 --- a/Plugins/SpellCheck/SpellCheck.plugin.js +++ b/Plugins/SpellCheck/SpellCheck.plugin.js @@ -63,7 +63,7 @@ class SpellCheck { dictionaryLanguage: {value:"en", description:"Dictionay Language:"} }, amounts: { - maxSimilarAmount: {value:6, description:"Maximal Amount of suggested Words:"} + maxSimilarAmount: {value:6, min:1, max:30, description:"Maximal Amount of suggested Words:"} } }; } @@ -81,7 +81,7 @@ class SpellCheck { settingshtml += `

${this.defaults.choices[key].description}

${this.languages[choices[key]].name}
`; } for (let key in amounts) { - settingshtml += `

${this.defaults.amounts[key].description}

`; + settingshtml += `

${this.defaults.amounts[key].description}

`; } var ownDictionary = BDFDB.loadData(choices.dictionaryLanguage, this, "owndics") || []; settingshtml += `

Your own Dictionary:

`; @@ -97,10 +97,6 @@ class SpellCheck { BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {this.openDropdownMenu(settingspanel, e);}); BDFDB.addEventListener(this, settingspanel, "click", ".remove-word", e => {this.removeFromOwnDictionarye;}); - BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => { - var input = parseInt(e.currentTarget.value); - if (!isNaN(input) && input > -1) BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts"); - }); return settingspanel; } diff --git a/Plugins/StalkerNotifications/StalkerNotifications.plugin.js b/Plugins/StalkerNotifications/StalkerNotifications.plugin.js index cf289ac52e..8082a380be 100644 --- a/Plugins/StalkerNotifications/StalkerNotifications.plugin.js +++ b/Plugins/StalkerNotifications/StalkerNotifications.plugin.js @@ -10,6 +10,10 @@ class StalkerNotifications { getDescription () {return "Lets you observe the status of people that aren't your friends.";} initConstructor () { + this.patchModules = { + "StandardSidebarView":"componentWillUnmount" + }; + this.stalkerOnlineList = {}; this.checkInterval = null; @@ -129,7 +133,7 @@ class StalkerNotifications { desktopoffline: {value:{url:null,song:null,mute:false}} }, amounts: { - checkInterval: {value:10, description:"Check Users every X seconds:"} + checkInterval: {value:10, min:5, description:"Check Users every X seconds:"} } }; } @@ -144,7 +148,7 @@ class StalkerNotifications { let settingshtml = `
${this.name}
`; settingshtml += `

Add User:

`; for (let key in amounts) { - settingshtml += `

${this.defaults.amounts[key].description}

`; + settingshtml += `

${this.defaults.amounts[key].description}

`; } for (let key in settings) { settingshtml += `

${this.defaults.settings[key].description}

`; @@ -240,14 +244,6 @@ class StalkerNotifications { else BDFDB.showToast("Please enter a valid UserID.",{type:"error"}); }); BDFDB.addEventListener(this, settingspanel, "click", ".btn-timelog", () => {this.showTimeLog();}); - BDFDB.addEventListener(this, settingspanel, "input", ".amountInput", e => { - let input = parseInt(e.currentTarget.value); - if (!isNaN(input) && input > 0) { - BDFDB.saveData(e.currentTarget.getAttribute("option"), input, this, "amounts"); - this.startInterval(); - } - else e.currentTarget.value = 1; - }); return settingspanel; } @@ -343,6 +339,13 @@ class StalkerNotifications { return `
`; } + processStandardSidebarView (instance, wrapper) { + if (this.SettingsUpdated) { + delete this.SettingsUpdated; + this.startInterval(); + } + } + startInterval () { clearInterval(this.checkInterval); this.checkInterval = setInterval(() => {