From 40a019957ffc39297b04de17c3df1d30d7a4f174 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Thu, 9 Apr 2020 09:29:38 +0200 Subject: [PATCH] stuff --- Plugins/EditUsers/EditUsers.plugin.js | 53 +++++++---- Plugins/OwnerTag/OwnerTag.plugin.js | 88 +++++++++++-------- .../TopRoleEverywhere.plugin.js | 29 +++--- 3 files changed, 106 insertions(+), 64 deletions(-) diff --git a/Plugins/EditUsers/EditUsers.plugin.js b/Plugins/EditUsers/EditUsers.plugin.js index 0d9e57815a..6c35b8808e 100644 --- a/Plugins/EditUsers/EditUsers.plugin.js +++ b/Plugins/EditUsers/EditUsers.plugin.js @@ -4,7 +4,7 @@ var EditUsers = (_ => { return class EditUsers { getName () {return "EditUsers";} - getVersion () {return "3.8.2";} + getVersion () {return "3.8.3";} getAuthor () {return "DevilBro";} @@ -12,7 +12,7 @@ var EditUsers = (_ => { constructor () { this.changelog = { - "fixed":[["DM Call","Works again in private calls"]] + "fixed":[["Tags","Properly work again"]] }; this.patchedModules = { @@ -329,32 +329,40 @@ var EditUsers = (_ => { processNameTag (e) { if (e.instance.props.user && e.instance.props.className) { - let change = false, guildId = null, options = {changeBackground: false}, botClass = ""; + let change = false, guildId = null; + let changeBackground = false; + let tagClass = ""; switch (e.instance.props.className) { case BDFDB.disCN.userpopoutheadertagnonickname: change = BDFDB.DataUtils.get(this, "settings", "changeInUserPopout"); guildId = BDFDB.LibraryModules.LastGuildStore.getGuildId(); - options.changeBackground = true; - botClass = BDFDB.disCN.bottagnametag; + changeBackground = true; + tagClass = BDFDB.disCN.bottagnametag; break; case BDFDB.disCN.userprofilenametag: change = BDFDB.DataUtils.get(this, "settings", "changeInUserProfile"); guildId = BDFDB.LibraryModules.LastGuildStore.getGuildId(); - options.changeBackground = true; - botClass = BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag; + changeBackground = true; + tagClass = BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag; break; case BDFDB.disCN.guildsettingsinviteusername: change = BDFDB.DataUtils.get(this, "settings", "changeInMemberLog"); break; case BDFDB.disCN.userinfodiscordtag: change = BDFDB.DataUtils.get(this, "settings", "changeInFriendList"); - botClass = BDFDB.disCN.bottagnametag; + tagClass = BDFDB.disCN.bottagnametag; break; } if (change) { let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.username]]}); - if (index > -1) this.changeUserColor(children[index], e.instance.props.user.id, options); - if (botClass) this.injectBadge(e.returnvalue.props.children, e.instance.props.user.id, guildId, 2, botClass, e.instance.props.invertBotTagColor); + if (index > -1) this.changeUserColor(children[index], e.instance.props.user.id, { + changeBackground: changeBackground + }); + if (tagClass) this.injectBadge(e.returnvalue.props.children, e.instance.props.user.id, guildId, 2, { + tagClass: tagClass, + useRem: e.instance.props.useRemSizes, + inverted: e.instance.props.invertBotTagColor + }); } } } @@ -377,7 +385,10 @@ var EditUsers = (_ => { let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutheadernickname]]}); if (index > -1) { this.changeUserColor(children[index], e.instance.props.user.id, {changeBackground:true}); - this.injectBadge(children, e.instance.props.user.id, BDFDB.LibraryModules.LastGuildStore.getGuildId(), 2, BDFDB.disCN.bottagnametag, !!e.instance.props.activity); + this.injectBadge(children, e.instance.props.user.id, BDFDB.LibraryModules.LastGuildStore.getGuildId(), 2, { + tagClass: BDFDB.disCN.bottagnametag, + inverted: !!e.instance.props.activity + }); } } } @@ -520,7 +531,10 @@ var EditUsers = (_ => { } else this.changeUserColor(children[index], e.instance.props.message.author.id); } - this.injectBadge(children, e.instance.props.message.author.id, (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id, 2, e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); + this.injectBadge(children, e.instance.props.message.author.id, (BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.message.channel_id) || {}).guild_id, 2, { + tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy, + useRem: true + }); } } } @@ -593,7 +607,9 @@ var EditUsers = (_ => { } else { this.changeUserColor(e.returnvalue.props.name, e.instance.props.user.id, {changeBackground: true}); - this.injectBadge(BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user.id, BDFDB.LibraryModules.LastGuildStore.getGuildId(), 2, BDFDB.disCN.bottagmember); + this.injectBadge(BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user.id, BDFDB.LibraryModules.LastGuildStore.getGuildId(), 2, { + tagClass: BDFDB.disCN.bottagmember + }); } } } @@ -860,17 +876,18 @@ var EditUsers = (_ => { return BDFDB.LibraryModules.IconUtils.getUserAvatarURL(user); } - injectBadge (children, userId, guildId, insertIndex, botClass = "", inverted = false) { + injectBadge (children, userId, guildId, insertIndex, config = {}) { if (!BDFDB.ArrayUtils.is(children) || !userId) return; let data = BDFDB.DataUtils.load(this, "users", userId); if (data && data.tag) { let memberColor = data.ignoreTagColor && (BDFDB.LibraryModules.MemberStore.getMember(guildId, userId) || {}).colorString; - let fontColor = !inverted ? data.color4 : (memberColor || data.color3); - let backgroundColor = !inverted ? (memberColor || data.color3) : data.color4; + let fontColor = !config.inverted ? data.color4 : (memberColor || data.color3); + let backgroundColor = !config.inverted ? (memberColor || data.color3) : data.color4; let fontGradient = BDFDB.ObjectUtils.is(fontColor); children.splice(insertIndex, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, { - className: botClass, - invertColor: inverted, + className: config.tagClass, + useRemSizes: config.useRem, + invertColor: config.inverted, style: { background: BDFDB.ObjectUtils.is(backgroundColor) ? BDFDB.ColorUtils.createGradient(backgroundColor) : BDFDB.ColorUtils.convert(backgroundColor, "RGBA"), color: fontGradient ? BDFDB.ColorUtils.convert(fontColor[0], "RGBA") : BDFDB.ColorUtils.convert(fontColor, "RGBA") diff --git a/Plugins/OwnerTag/OwnerTag.plugin.js b/Plugins/OwnerTag/OwnerTag.plugin.js index c4597307cd..d81d223360 100644 --- a/Plugins/OwnerTag/OwnerTag.plugin.js +++ b/Plugins/OwnerTag/OwnerTag.plugin.js @@ -1,10 +1,16 @@ //META{"name":"OwnerTag","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/OwnerTag","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/OwnerTag/OwnerTag.plugin.js"}*// var OwnerTag = (_ => { + const userTypes = { + NONE: 0, + ADMIN: 1, + OWNER: 2 + }; + return class OwnerTag { getName () {return "OwnerTag";} - getVersion () {return "1.2.7";} + getVersion () {return "1.2.8";} getAuthor () {return "DevilBro";} @@ -12,7 +18,7 @@ var OwnerTag = (_ => { constructor () { this.changelog = { - "fixed":[["Messages Popout","Now works in popouts like the recent mentions popout"]] + "fixed":[["Tags","Properly work again"]] }; this.patchedModules = { @@ -154,53 +160,64 @@ var OwnerTag = (_ => { } processMemberListItem (e) { - let usertype = this.getUserType(e.instance.props.user); - if (usertype && BDFDB.DataUtils.get(this, "settings", "addInMemberList")) { - this.injectOwnerTag(BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, usertype, 1, BDFDB.disCN.bottagmember); + let userType = this.getUserType(e.instance.props.user); + if (userType && BDFDB.DataUtils.get(this, "settings", "addInMemberList")) { + this.injectOwnerTag(BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, userType, 1, { + tagClass: BDFDB.disCN.bottagmember + }); } } processMessageHeader (e) { if (e.instance.props.message && BDFDB.DataUtils.get(this, "settings", "addInChatWindow")) { - let usertype = this.getUserType(e.instance.props.message.author); - if (usertype) { + let userType = this.getUserType(e.instance.props.message.author); + if (userType) { let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]}); - if (index > -1) this.injectOwnerTag(children, e.instance.props.message.author, usertype, e.instance.props.compact ? 0 : 2, e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); + if (index > -1) this.injectOwnerTag(children, e.instance.props.message.author, userType, e.instance.props.compact ? 0 : 2, { + tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy, + useRem: true + }); } } } processNameTag (e) { if (e.instance.props.user && e.instance.props.className) { - let usertype = this.getUserType(e.instance.props.user); - if (usertype) { - let inject = false, bottag = ""; + let userType = this.getUserType(e.instance.props.user); + if (userType) { + let inject = false, tagClass = ""; switch (e.instance.props.className) { case BDFDB.disCN.userpopoutheadertagnonickname: inject = BDFDB.DataUtils.get(this, "settings", "addInUserPopout"); - bottag = BDFDB.disCN.bottagnametag; + tagClass = BDFDB.disCN.bottagnametag; break; case BDFDB.disCN.userprofilenametag: inject = BDFDB.DataUtils.get(this, "settings", "addInUserProfile"); - bottag = BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag; + tagClass = BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag; break; } - if (inject) this.injectOwnerTag(e.returnvalue.props.children, e.instance.props.user, usertype, 2, bottag); + if (inject) this.injectOwnerTag(e.returnvalue.props.children, e.instance.props.user, userType, 2, { + tagClass: tagClass, + useRem: e.instance.props.useRemSizes, + inverted: e.instance.props.invertBotTagColor + }); } } } processUserPopout (e) { if (e.instance.props.user && BDFDB.DataUtils.get(this, "settings", "addInUserPopout")) { - let usertype = this.getUserType(e.instance.props.user); - if (usertype) { + let userType = this.getUserType(e.instance.props.user); + if (userType) { let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutheadertagwithnickname]]}); - if (index > -1) this.injectOwnerTag(children, e.instance.props.user, usertype, 2, BDFDB.disCNS.userpopoutheaderbottagwithnickname + BDFDB.disCN.bottagnametag); + if (index > -1) this.injectOwnerTag(children, e.instance.props.user, userType, 2, { + tagClass: BDFDB.disCNS.userpopoutheaderbottagwithnickname + BDFDB.disCN.bottagnametag + }); } } } - injectOwnerTag (children, user, usertype, insertindex, tagclass = "", inverted = false) { + injectOwnerTag (children, user, userType, insertIndex, config = {}) { if (!BDFDB.ArrayUtils.is(children) || !user) return; let settings = BDFDB.DataUtils.get(this, "settings"); if (settings.useCrown || settings.hideNativeCrown) { @@ -209,10 +226,10 @@ var OwnerTag = (_ => { } let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()); let member = settings.useRoleColor ? (BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, user.id) || {}) : {}; - let isOwner = usertype == 2; + let isOwner = userType == userTypes.OWNER; let tag = null; if (settings.useCrown) { - let label = isOwner ? (channel.type == 3 ? BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER : BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER) : BDFDB.LanguageUtils.LanguageStrings.ADMINISTRATOR; + let label = isOwner ? (channel.type == BDFDB.DiscordConstants.ChannelTypes.GROUP_DM ? BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER : BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER) : BDFDB.LanguageUtils.LanguageStrings.ADMINISTRATOR; tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { text: label, children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { @@ -223,30 +240,31 @@ var OwnerTag = (_ => { }); } else { - let tagcolor = BDFDB.ColorUtils.convert(member.colorString, "RGBA"); - let isbright = BDFDB.ColorUtils.isBright(tagcolor); - tagcolor = isbright ? (settings.useBlackFont ? tagcolor : BDFDB.ColorUtils.change(tagcolor, -0.3)) : tagcolor; + let tagColor = BDFDB.ColorUtils.convert(member.colorString, "RGBA"); + let isBright = BDFDB.ColorUtils.isBright(tagColor); + tagColor = isBright ? (settings.useBlackFont ? tagColor : BDFDB.ColorUtils.change(tagColor, -0.3)) : tagColor; tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, { - className: tagclass, - tag: BDFDB.DataUtils.get(this, "inputs", isOwner ? "ownTagName" : "ownAdminTagName"), - invertColor: inverted, + className: config.tagClass, + useRemSizes: config.useRem, + invertColor: config.inverted, style: { - backgroundColor: inverted ? (isbright && settings.useBlackFont ? "black" : null) : tagcolor, - color: !inverted ? (isbright && settings.useBlackFont ? "black" : null) : tagcolor - } + backgroundColor: config.inverted ? (isBright && settings.useBlackFont ? "black" : null) : tagColor, + color: !config.inverted ? (isBright && settings.useBlackFont ? "black" : null) : tagColor + }, + tag: BDFDB.DataUtils.get(this, "inputs", isOwner ? "ownTagName" : "ownAdminTagName") }); } - children.splice(insertindex, 0, tag); + children.splice(insertIndex, 0, tag); } getUserType (user) { - if (!user) return 0; + if (!user) return userTypes.NONE; let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()); - if (!channel) return 0; + if (!channel) return userTypes.NONE; let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id); - let isowner = channel.ownerId == user.id || guild && guild.ownerId == user.id; - if (!(isowner || (BDFDB.DataUtils.get(this, "settings", "addForAdmins") && BDFDB.UserUtils.can("ADMINISTRATOR", user.id)))) return 0; - return isowner ? 2 : 1; + let isOwner = channel.ownerId == user.id || guild && guild.ownerId == user.id; + if (!(isOwner || (BDFDB.DataUtils.get(this, "settings", "addForAdmins") && BDFDB.UserUtils.can("ADMINISTRATOR", user.id)))) return userTypes.NONE; + return isOwner ? userTypes.OWNER : userTypes.ADMIN; } forceUpdateAll () { diff --git a/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js b/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js index e275d639b2..62b89b1223 100644 --- a/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js +++ b/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js @@ -4,7 +4,7 @@ var TopRoleEverywhere = (_ => { return class TopRoleEverywhere { getName () {return "TopRoleEverywhere";} - getVersion () {return "2.9.9";} + getVersion () {return "3.0.0";} getAuthor () {return "DevilBro";} @@ -12,9 +12,9 @@ var TopRoleEverywhere = (_ => { constructor () { this.changelog = { - "fixed":[["Compact","Fuck u compact mode"]] + "fixed":[["Tags","Properly work again"]] }; - + this.patchedModules = { after: { MemberListItem: "render", @@ -158,18 +158,23 @@ var TopRoleEverywhere = (_ => { processMemberListItem (e) { if (e.instance.props.user && BDFDB.DataUtils.get(this, "settings", "showInMemberList")) { - this.injectRoleTag(BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "member", BDFDB.disCN.bottagmember); + this.injectRoleTag(BDFDB.ReactUtils.getValue(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "member", { + tagClass: BDFDB.disCN.bottagmember + }); } } processMessageHeader (e) { if (e.instance.props.message && BDFDB.DataUtils.get(this, "settings", "showInChat")) { let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]}); - if (index > -1) this.injectRoleTag(children, e.instance.props.message.author, "chat", e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy); + if (index > -1) this.injectRoleTag(children, e.instance.props.message.author, "chat", { + tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy, + useRem: true + }); } } - injectRoleTag (children, user, type, tagclass) { + injectRoleTag (children, user, type, config = {}) { if (!BDFDB.ArrayUtils.is(children) || !user) return; let guild = BDFDB.LibraryModules.GuildStore.getGuild(BDFDB.LibraryModules.LastGuildStore.getGuildId()); let settings = BDFDB.DataUtils.get(this, "settings"); @@ -184,24 +189,26 @@ var TopRoleEverywhere = (_ => { } if (role && (role.colorString || settings.includeColorless)) children.push(this.createRoleTag(settings, Object.assign({}, role, { name: settings.showOwnerRole && user.id == guild.ownerId ? BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER : role.name - }), type, tagclass)); + }), type, config)); if (type == "chat" && settings.addUserID) children.push(this.createRoleTag(settings, { name: user.id - }, type, tagclass)); + }, type, config)); } - createRoleTag (settings, role, type, tagclass) { + createRoleTag (settings, role, type, config = {}) { if (settings.useOtherStyle) { let tagColor = BDFDB.ColorUtils.convert(role.colorString || BDFDB.DiscordConstants.Colors.PRIMARY_DARK_500, "RGB") let isBright = role.colorString && BDFDB.ColorUtils.isBright(tagColor); tagColor = isBright ? (settings.useBlackFont ? tagColor : BDFDB.ColorUtils.change(tagColor, -0.3)) : tagColor; return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, { - className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._toproleseverywheretag, BDFDB.disCN[`_toproleseverywhere${type}tag`], BDFDB.disCN._toproleseverywherebadgestyle, tagclass), - tag: role.name, + className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._toproleseverywheretag, BDFDB.disCN[`_toproleseverywhere${type}tag`], BDFDB.disCN._toproleseverywherebadgestyle, config.tagClass), + useRemSizes: config.useRem, + invertColor: config.inverted, style: { backgroundColor: tagColor, color: isBright && settings.useBlackFont ? "black" : null }, + tag: role.name, onContextMenu: role.id ? e => {this.openRoleContextMenu(e, role);} : null }); }