From 287e9495a9fd9dbc16acdfc55c30be0e53ee545b Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 24 Feb 2021 17:32:17 +0100 Subject: [PATCH] stuff --- Library/0BDFDB.plugin.js | 10 ++++---- Plugins/EditChannels/EditChannels.plugin.js | 12 ++++----- Plugins/EditUsers/EditUsers.plugin.js | 17 +++++++------ .../RemoveBlockedMessages.plugin.js | 20 ++++++++++----- .../RemoveNicknames/RemoveNicknames.plugin.js | 25 ++++++++++--------- 5 files changed, 47 insertions(+), 37 deletions(-) diff --git a/Library/0BDFDB.plugin.js b/Library/0BDFDB.plugin.js index 2ea674991b..e93bcca959 100644 --- a/Library/0BDFDB.plugin.js +++ b/Library/0BDFDB.plugin.js @@ -16,13 +16,13 @@ module.exports = (_ => { "info": { "name": "BDFDB", "author": "DevilBro", - "version": "1.3.9", + "version": "1.4.0", "description": "Give other plugins utility functions" }, "rawUrl": "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", "changeLog": { - "fixed": { - "Color Picker": "Fixed Issue with Color Swatches Component" + "progress": { + "New Meta Headers": "Adjusted Update Check for new Plugin Meta Headers" } } }; @@ -619,7 +619,7 @@ module.exports = (_ => { LibraryRequires.request(url, (error, response, body) => { if (error || !PluginStores.updateData.plugins[url]) return callback(null); let newName = (body.match(/"name"\s*:\s*"([^"]+)"/) || [])[1] || pluginName; - let newVersion = (body.match(/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i) || "").toString().replace(/['"]/g, ""); + let newVersion = (body.match(/@version ([0-9]+\.[0-9]+\.[0-9]+)|['"]([0-9]+\.[0-9]+\.[0-9]+)['"]/i) || []).filter(n => n)[1]; if (!newVersion) return callback(null); if (pluginName == newName && BDFDB.NumberUtils.getVersionDifference(newVersion, PluginStores.updateData.plugins[url].version) > 0.2) { BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_force_updated", pluginName), { @@ -773,7 +773,7 @@ module.exports = (_ => { else { let wasEnabled = BDFDB.BDUtils.isPluginEnabled(pluginName); let newName = (body.match(/"name"\s*:\s*"([^"]+)"/) || [])[1] || pluginName; - let newVersion = body.match(/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i).toString().replace(/['"]/g, ""); + let newVersion = (body.match(/@version ([0-9]+\.[0-9]+\.[0-9]+)|['"]([0-9]+\.[0-9]+\.[0-9]+)['"]/i) || []).filter(n => n)[1]; let oldVersion = PluginStores.updateData.plugins[url].version; let fileName = pluginName == "BDFDB" ? "0BDFDB" : pluginName; let newFileName = newName == "BDFDB" ? "0BDFDB" : newName; diff --git a/Plugins/EditChannels/EditChannels.plugin.js b/Plugins/EditChannels/EditChannels.plugin.js index 5b204bdefd..a8030b8b54 100644 --- a/Plugins/EditChannels/EditChannels.plugin.js +++ b/Plugins/EditChannels/EditChannels.plugin.js @@ -14,12 +14,12 @@ module.exports = (_ => { "info": { "name": "EditChannels", "author": "DevilBro", - "version": "4.2.5", - "description": "Allow you to rename and recolor channelnames" + "version": "4.2.6", + "description": "Allow you to rename and recolor Channel Names" }, "changeLog": { - "improved": { - "Canary Changes": "Preparing Plugins for the changes that are already done on Discord Canary" + "fixed": { + "Mentions": "" } } }; @@ -108,7 +108,7 @@ module.exports = (_ => { QuickSwitchChannelResult: "render", SearchResultsInner: "default", RecentsChannelHeader: "default", - ChannelMention: "ChannelMention" + RichChannelMention: "ChannelMention" } }; @@ -508,7 +508,7 @@ module.exports = (_ => { } } - processChannelMention (e) { + processRichChannelMention (e) { if (e.instance.props.id && settings.changeInMentions) { let name = (changedChannels[e.instance.props.id] || {}).name; let color = this.getChannelDataColor(e.instance.props.id); diff --git a/Plugins/EditUsers/EditUsers.plugin.js b/Plugins/EditUsers/EditUsers.plugin.js index 6fd53dd739..05515fa3e5 100644 --- a/Plugins/EditUsers/EditUsers.plugin.js +++ b/Plugins/EditUsers/EditUsers.plugin.js @@ -14,12 +14,12 @@ module.exports = (_ => { "info": { "name": "EditUsers", "author": "DevilBro", - "version": "4.1.5", + "version": "4.1.6", "description": "Allow you to change the icon, name, tag and color of users" }, "changeLog": { "fixed": { - "Incoming Call Popup": "" + "Mentions": "" } } }; @@ -148,8 +148,8 @@ module.exports = (_ => { MessageContent: "type", Reaction: "render", ReactorsComponent: "render", - Mention: "default", - UserMention: "UserMention", + UserMention: "default", + RichUserMention: "UserMention", ChannelReply: "default", MemberListItem: "render", UserHook: "render", @@ -393,7 +393,7 @@ module.exports = (_ => { } processNameTag (e) { - if (e.instance.props.user && (e.instance.props.className || e.instance.props.usernameClass)) { + if (e.returnvalue && e.instance.props.user && (e.instance.props.className || e.instance.props.usernameClass)) { let change = false, guildId = null; let changeBackground = false; let tagClass = ""; @@ -717,13 +717,14 @@ module.exports = (_ => { } } - processMention (e) { + processUserMention (e) { if (e.instance.props.userId && settings.changeInMentions && changedUsers[e.instance.props.userId] && this.shouldChangeInChat()) { - this.changeMention(e.returnvalue, changedUsers[e.instance.props.userId]); + let mention = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "Mention"}); + if (mention) this.changeMention(mention, changedUsers[e.instance.props.userId]); } } - processUserMention (e) { + processRichUserMention (e) { if (e.instance.props.id && settings.changeInMentions && changedUsers[e.instance.props.id] && this.shouldChangeInChat()) { let data = changedUsers[e.instance.props.id]; let tooltipChildren = BDFDB.ObjectUtils.get(e, "returnvalue.props.text.props.children"); diff --git a/Plugins/RemoveBlockedMessages/RemoveBlockedMessages.plugin.js b/Plugins/RemoveBlockedMessages/RemoveBlockedMessages.plugin.js index 7b7e6020d7..87cd905573 100644 --- a/Plugins/RemoveBlockedMessages/RemoveBlockedMessages.plugin.js +++ b/Plugins/RemoveBlockedMessages/RemoveBlockedMessages.plugin.js @@ -14,12 +14,12 @@ module.exports = (_ => { "info": { "name": "RemoveBlockedMessages", "author": "DevilBro", - "version": "1.2.3", + "version": "1.2.4", "description": "Removes blocked messages/users completely" }, "changeLog": { "fixed": { - "Update Reactions": "Fixed issue where reaction sometimes wouldn't show up at all, really now" + "Mentions": "" } } }; @@ -103,7 +103,8 @@ module.exports = (_ => { Reactions: "render", MemberListItem: "render", VoiceUser: "render", - Mention: "default" + UserMention: "default", + RichUserMention: "UserMention" } }; @@ -373,9 +374,16 @@ module.exports = (_ => { if (settings.removeUsers && BDFDB.ArrayUtils.is(e.instance.props.users)) e.instance.props.users = [].concat(e.instance.props.users).filter(n => !n || !BDFDB.LibraryModules.FriendUtils.isBlocked(n.id)); } - processMention (e) { - if (settings.removeMentions && e.instance.props.userId && BDFDB.LibraryModules.FriendUtils.isBlocked(e.instance.props.userId)) return BDFDB.ReactUtils.createElement("span", { - className: BDFDB.disCNS.mention + BDFDB.disCN.mentionwrapper, + processUserMention (e) { + if (e.instance.props.userId && settings.removeMentions && BDFDB.LibraryModules.FriendUtils.isBlocked(e.instance.props.userId)) return BDFDB.ReactUtils.createElement("span", { + className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.mention, BDFDB.disCN.mentionwrapper, e.instance.props.className), + children: ["@" + BDFDB.LanguageUtils.LanguageStrings.UNKNOWN_USER] + }); + } + + processRichUserMention (e) { + if (e.instance.props.id && settings.removeMentions && BDFDB.LibraryModules.FriendUtils.isBlocked(e.instance.props.id)) return BDFDB.ReactUtils.createElement("span", { + className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.mention, BDFDB.disCN.mentionwrapper, e.instance.props.className), children: ["@" + BDFDB.LanguageUtils.LanguageStrings.UNKNOWN_USER] }); } diff --git a/Plugins/RemoveNicknames/RemoveNicknames.plugin.js b/Plugins/RemoveNicknames/RemoveNicknames.plugin.js index eb70481ba7..1c0f2b0fdb 100644 --- a/Plugins/RemoveNicknames/RemoveNicknames.plugin.js +++ b/Plugins/RemoveNicknames/RemoveNicknames.plugin.js @@ -14,12 +14,12 @@ module.exports = (_ => { "info": { "name": "RemoveNicknames", "author": "DevilBro", - "version": "1.3.6", + "version": "1.3.7", "description": "Replace all nicknames with the actual accountnames" }, "changeLog": { "fixed": { - "Messages": "Works in messages again" + "Mentions": "" } } }; @@ -68,10 +68,10 @@ module.exports = (_ => { onLoad () { this.defaults = { settings: { - replaceOwn: {value: false, inner: false, description: "Replace your own name: "}, - replaceBots: {value: true, inner: false, description: "Replace the nickname of bots: "}, - addNickname: {value: false, inner: false, description: "Add nickname as parentheses: "}, - swapPositions: {value: false, inner: false, description: "Swap the position of username and nickname: "}, + replaceOwn: {value: false, inner: false, description: "Replace your own Name"}, + replaceBots: {value: true, inner: false, description: "Replace the Nickname of Bots"}, + addNickname: {value: false, inner: false, description: "Add Nickname as Parentheses"}, + swapPositions: {value: false, inner: false, description: "Swap the Position of Username and Nickname"}, changeInChatWindow: {value: true, inner: true, description: "Messages"}, changeInReactions: {value: true, inner: true, description: "Reactions"}, changeInMentions: {value: true, inner: true, description: "Mentions"}, @@ -92,8 +92,8 @@ module.exports = (_ => { after: { TypingUsers: "render", Reaction: "render", - Mention: "default", - UserMention: "UserMention" + UserMention: "default", + RichUserMention: "UserMention" } }; } @@ -197,14 +197,15 @@ module.exports = (_ => { }); } - processMention (e) { + processUserMention (e) { if (e.instance.props.userId && settings.changeInMentions) { - let newName = this.getNewName(BDFDB.LibraryModules.UserStore.getUser(e.instance.props.userId)); - if (newName) e.returnvalue.props.children[0] = "@" + newName; + let mention = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "Mention"}); + let newName = mention && this.getNewName(BDFDB.LibraryModules.UserStore.getUser(e.instance.props.userId)); + if (newName) mention.props.children[0] = "@" + newName; } } - processUserMention (e) { + processRichUserMention (e) { if (e.instance.props.id && settings.changeInMentions && typeof e.returnvalue.props.children == "function") { let newName = this.getNewName(BDFDB.LibraryModules.UserStore.getUser(e.instance.props.id)); if (newName) {