//META{"name":"EditUsers","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditUsers","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditUsers/EditUsers.plugin.js"}*// class EditUsers { getName () {return "EditUsers";} getVersion () {return "3.6.5";} getAuthor () {return "DevilBro";} getDescription () {return "Allows you to change the icon, name, tag and color of users.";} constructor () { this.changelog = { "fixed":[["Tooltips","Fixed issue where native tooltip wasn't hidden"]] }; this.labels = {}; this.patchModules = { "ChannelTextArea":"componentDidMount", "MemberListItem":["componentDidMount","componentDidUpdate"], "UserPopout":["componentDidMount","componentDidUpdate"], "UserProfile":["componentDidMount","componentDidUpdate"], "FriendRow":"componentDidMount", "VoiceUser":["componentDidMount","componentDidUpdate"], "Account":["componentDidMount","componentDidUpdate"], "AuditLog":"componentDidMount", "BannedCard":"render", "InviteCard":"render", "MemberCard":"render", "InvitationCard":"componentDidMount", "TypingUsers":"componentDidUpdate", "MessageUsername":["componentDidMount","componentDidUpdate"], "DirectMessage":"componentDidMount", "CallAvatar":"componentDidMount", "VideoTile":"componentDidMount", "PictureInPictureVideo":"componentDidMount", "PrivateChannel":["componentDidMount","componentDidUpdate"], "HeaderBar":["componentDidMount","componentDidUpdate"], "HeaderBarContainer":["componentDidMount","componentDidUpdate"], "Clickable":"componentDidMount", "MessageContent":["componentDidMount","componentDidUpdate"], "StandardSidebarView":"componentWillUnmount" }; } initConstructor () { this.avatarselector = BDFDB.dotCNC.guildicon + BDFDB.dotCNC.avatar + BDFDB.dotCNC.callavatarwrapper + BDFDB.dotCN.voiceavatarcontainer; this.css = ` ${BDFDB.dotCN.bottag} { line-height: 13px; height: 13px; top: unset; bottom: 0px; position: relative; margin: 0 0 0 1ch; } ${BDFDB.dotCN.userpopoutheaderbottagwithnickname} { bottom: 4px; } ${BDFDB.dotCN.userpopoutheaderbottagwithnickname} { bottom: 0px; } ${BDFDB.dotCNS.userpopoutheadernamewrapper + BDFDB.dotCN.bottag}, ${BDFDB.dotCN.userprofilebottag}, ${BDFDB.dotCN.bottagmessagecozy} { bottom: 2px; } ${BDFDB.dotCN.bottagmessagecompact} { margin-right: 6px; bottom: 3px; }`; this.defaults = { settings: { changeInChatTextarea: {value:true, inner:true, description:"Chat Textarea"}, changeInChatWindow: {value:true, inner:true, description:"Messages"}, changeInMentions: {value:true, inner:true, description:"Mentions"}, changeInVoiceChat: {value:true, inner:true, description:"Voice Channels"}, changeInMemberList: {value:true, inner:true, description:"Member List"}, changeInRecentDms: {value:true, inner:true, description:"Direct Message Notifications"}, changeInDmsList: {value:true, inner:true, description:"Direct Message List"}, changeInDmHeader: {value:true, inner:true, description:"Direct Message Header"}, changeInDmCalls: {value:true, inner:true, description:"Calls/ScreenShares"}, changeInTyping: {value:true, inner:true, description:"Typing List"}, changeInFriendList: {value:true, inner:true, description:"Friend List"}, changeInInviteList: {value:true, inner:true, description:"Invite List"}, changeInActivity: {value:true, inner:true, description:"Activity Page"}, changeInUserPopout: {value:true, inner:true, description:"User Popouts"}, changeInUserProfil: {value:true, inner:true, description:"User Profile Modal"}, changeInAutoComplete: {value:true, inner:true, description:"Autocomplete Menu"}, changeInAuditLog: {value:true, inner:true, description:"Audit Log"}, changeInMemberLog: {value:true, inner:true, description:"Member Log"}, changeInSearchPopout: {value:true, inner:true, description:"Search Popout"}, changeInUserAccount: {value:true, inner:true, description:"Your Account Information"}, changeInAppTitle: {value:true, inner:true, description:"Discord App Title (DMs)"} } }; } getSettingsPanel () { if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; var settings = BDFDB.getAllData(this, "settings"); var settingsitems = [], inneritems = []; for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, { className: BDFDB.disCN.marginbottom8, plugin: this, keys: ["settings", key], label: this.defaults.settings[key].description, value: settings[key] })); settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, { title: "Change Users in:", children: inneritems })); settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { type: "Button", className: BDFDB.disCN.marginbottom8, color: BDFDB.LibraryComponents.Button.Colors.RED, label: "Reset all Users", onClick: _ => { BDFDB.openConfirmModal(this, "Are you sure you want to reset all users?", () => { BDFDB.removeAllData(this, "users"); this.forceUpdateAll(); }); }, children: BDFDB.LanguageUtils.LanguageStrings.RESET })); return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems); } //legacy load () {} start () { if (!global.BDFDB) global.BDFDB = {myPlugins:{}}; if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this; var libraryScript = document.querySelector('head script#BDFDBLibraryScript'); if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) { if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); libraryScript.setAttribute("id", "BDFDBLibraryScript"); libraryScript.setAttribute("type", "text/javascript"); libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js"); libraryScript.setAttribute("date", performance.now()); libraryScript.addEventListener("load", () => {this.initialize();}); document.head.appendChild(libraryScript); } else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize(); this.startTimeout = setTimeout(() => {this.initialize();}, 30000); } initialize () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (this.started) return; BDFDB.PluginUtils.init(this); var observer = new MutationObserver(() => {this.changeAppTitle();}); BDFDB.ObserverUtils.connect(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true}); this.forceUpdateAll(); } else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!'); } stop () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { this.stopping = true; let data = BDFDB.loadAllData(this, "users"); BDFDB.removeAllData(this, "users"); try {this.forceUpdateAll();} catch (err) {} BDFDB.saveAllData(data, this, "users"); BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow"); BDFDB.PluginUtils.clear(this); } } // begin of own functions onUserContextMenu (instance, menu, returnvalue) { if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]}); const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { label: this.labels.context_localusersettings_text, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-usersettings-contextMenuSubItem`, render: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, { label: this.labels.submenu_usersettings_text, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-usersettings-ContextMenuItem`, action: e => { BDFDB.closeContextMenu(menu); this.showUserSettings(instance.props.user); } }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, { label: this.labels.submenu_resetsettings_text, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`, disabled: !BDFDB.loadData(instance.props.user.id, this, "users"), action: e => { BDFDB.closeContextMenu(menu); BDFDB.removeData(instance.props.user.id, this, "users"); this.forceUpdateAll(); } }) ] })] }) ] }); if (index > -1) children.splice(index, 0, itemgroup); else children.push(itemgroup); } } forceUpdateAll () { this.changeAppTitle(); BDFDB.ModuleUtils.forceAllUpdates(this); } showUserSettings (info) { let data = BDFDB.loadData(info.id, this, "users") || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}; BDFDB.openModal(this, { size: "MEDIUM", header: this.labels.modal_header_text, subheader: member.nick || info.username, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, { tab: this.labels.modal_tabheader1_text, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_username_text, className: BDFDB.disCN.marginbottom20 + " input-username", children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, { value: data.name, placeholder: member.nick || info.username, autoFocus: true }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_usertag_text, className: BDFDB.disCN.marginbottom20 + " input-usertag", children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, { value: data.tag }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_useravatar_text, className: BDFDB.disCN.marginbottom8 + " input-useravatar", children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, { inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null, inputId: "USERAVATAR", value: data.url, placeholder: BDFDB.UserUtils.getAvatar(info.id), disabled: data.removeIcon, onFocus: e => { this.createNoticeTooltip(e.target); }, onChange: (value, instance) => { this.checkUrl(value, instance); } }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { type: "Switch", className: BDFDB.disCN.marginbottom20 + " input-removeicon", label: this.labels.modal_removeicon_text, value: data.removeIcon, onChange: (value, instance) => { let avatarinputins = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {props:[["inputId","USERAVATAR"]]}); if (avatarinputins) { avatarinputins.props.inputClassName = null; avatarinputins.props.disabled = value; BDFDB.ReactUtils.forceUpdate(avatarinputins); } } }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, { tab: this.labels.modal_tabheader2_text, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_colorpicker1_text, className: BDFDB.disCN.marginbottom20, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, { color: data.color1, number: 1 }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_colorpicker2_text, className: BDFDB.disCN.marginbottom20, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, { color: data.color2, number: 2 }) ] }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, { tab: this.labels.modal_tabheader3_text, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_colorpicker3_text, className: BDFDB.disCN.marginbottom20, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, { color: data.color3, number: 3, disabled: data.ignoreTagColor }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: this.labels.modal_colorpicker4_text, className: BDFDB.disCN.marginbottom20, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, { color: data.color4, number: 4, disabled: data.ignoreTagColor }) ] }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { type: "Switch", className: BDFDB.disCN.marginbottom20 + " input-ignoretagcolor", label: this.labels.modal_ignoretagcolor_text, value: data.ignoreTagColor, onChange: (value, instance) => { let colorpicker3ins = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {props:[["number",3]]}); let colorpicker4ins = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {props:[["number",4]]}); if (colorpicker3ins) colorpicker3ins.setState({disabled: value}); if (colorpicker4ins) colorpicker4ins.setState({disabled: value}); } }) ] }) ], buttons: [{ contents: BDFDB.LanguageUtils.LanguageStrings.SAVE, color: "BRAND", close: true, click: modal => { let olddata = Object.assign({}, data); let usernameinput = modal.querySelector(".input-username " + BDFDB.dotCN.input); let usertaginput = modal.querySelector(".input-usertag " + BDFDB.dotCN.input); let useravatarinput = modal.querySelector(".input-useravatar " + BDFDB.dotCN.input); let removeiconinput = modal.querySelector(".input-removeicon " + BDFDB.dotCN.switchinner); let ignoretagcolorinput = modal.querySelector(".input-ignoretagcolor " + BDFDB.dotCN.switchinner); data.name = usernameinput.value.trim() || null; data.tag = usertaginput.value.trim() || null; data.url = (!data.removeIcon && BDFDB.containsClass(useravatarinput, BDFDB.disCN.inputsuccess) ? useravatarinput.value.trim() : null) || null; data.removeIcon = removeiconinput.checked; data.ignoreTagColor = ignoretagcolorinput.checked; data.color1 = BDFDB.getSwatchColor(modal, 1); data.color2 = BDFDB.getSwatchColor(modal, 2); data.color3 = BDFDB.getSwatchColor(modal, 3); data.color4 = BDFDB.getSwatchColor(modal, 4); let changed = false; if (Object.keys(data).every(key => data[key] == null || data[key] == false) && (changed = true)) BDFDB.removeData(info.id, this, "users"); else if (!BDFDB.equals(olddata, data) && (changed = true)) BDFDB.saveData(info.id, data, this, "users"); if (changed) this.forceUpdateAll(); } }] }); } processChannelTextArea (instance, wrapper, returnvalue) { let channel = BDFDB.ReactUtils.getValue(instance, "props.channel"); if (channel) { var textarea = wrapper.querySelector("textarea"); if (!textarea) return; if (channel.type == 1 && instance.props.type == "normal" && !instance.props.disabled) { let user = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]); if (user) { let data = this.getUserData(user.id, wrapper); textarea.setAttribute("placeholder", BDFDB.LanguageUtils.LanguageStrings.TEXTAREA_PLACEHOLDER.replace("{{channel}}", "@" + (data.name || user.username))); } } BDFDB.ListenerUtils.remove(this, textarea); if (BDFDB.getData("changeInAutoComplete", this, "settings")) { BDFDB.ListenerUtils.add(this, textarea, "keydown", e => { let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete); if (autocompletemenu && (e.which == 9 || e.which == 13)) { if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteEditUsersRow")) { BDFDB.ListenerUtils.stopEvent(e); this.swapWordWithMention(textarea); } } else if (autocompletemenu && (e.which == 38 || e.which == 40)) { let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteEditUsersSelector)"); let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected); if (BDFDB.containsClass(selected, "autocompleteEditUsersSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) { BDFDB.ListenerUtils.stopEvent(e); let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(next, BDFDB.disCN.autocompleteselected); } } else if (textarea.value && !e.shiftKey && e.which == 13 && !autocompletemenu && textarea.value.indexOf("s/") != 0) { this.format = true; textarea.dispatchEvent(new Event("input")); } else if (!e.ctrlKey && e.which != 16 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) { clearTimeout(textarea.EditUsersAutocompleteTimeout); textarea.EditUsersAutocompleteTimeout = setTimeout(() => {this.addAutoCompleteMenu(textarea, channel);},100); } if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow"); }); BDFDB.ListenerUtils.add(this, textarea, "click", e => { if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);}); }); } } } processMemberListItem (instance, wrapper, returnvalue) { let username = wrapper.querySelector(BDFDB.dotCN.memberusername); if (username) { this.changeName(instance.props.user, username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); this.addTag(instance.props.user, username.parentElement, BDFDB.disCN.bottagmember); } } processUserPopout (instance, wrapper, returnvalue) { let username = wrapper.querySelector(BDFDB.dotCNC.userpopoutheadertagusernamenonickname + BDFDB.dotCN.userpopoutheadernickname); if (username) { this.changeName(instance.props.user, username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); this.addTag(instance.props.user, username.parentElement, BDFDB.disCN.bottagnametag, wrapper); } } processUserProfile (instance, wrapper, returnvalue) { let username = wrapper.querySelector(BDFDB.dotCN.userprofileusername); if (username) { this.changeName(instance.props.user, username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); this.addTag(instance.props.user, username.parentElement, BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag, wrapper); } } processFriendRow (instance, wrapper, returnvalue) { let username = wrapper.querySelector(BDFDB.dotCN.friendsusername); if (username) { this.changeName(instance.props.user, username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); } } processVoiceUser (instance, wrapper, returnvalue) { let user = instance.props.user; if (user && wrapper.className) { this.changeVoiceUser(user, wrapper.querySelector(BDFDB.dotCN.voicename), instance.props.speaking); this.changeAvatar(user, this.getAvatarDiv(wrapper)); } } processAccount (instance, wrapper, returnvalue) { let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.child.stateNode.props.currentUser"); if (user) { this.changeName(user, wrapper.querySelector(BDFDB.dotCN.accountinfodetails).firstElementChild); this.changeAvatar(user, this.getAvatarDiv(wrapper)); } } processMessageUsername (instance, wrapper, returnvalue) { let message = BDFDB.ReactUtils.getValue(instance, "props.message"); if (message) { let username = wrapper.querySelector(BDFDB.dotCN.messageusername); if (username) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id) || {}; this.changeName(message.author, username, channel.guild_id); if (!BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.messageheadercompact)) this.changeAvatar(message.author, this.getAvatarDiv(wrapper)); let messagegroup = BDFDB.getParentEle(BDFDB.dotCN.messagegroup, wrapper); this.addTag(message.author, wrapper, BDFDB.containsClass(messagegroup, BDFDB.disCN.messagegroupcozy) ? BDFDB.disCN.bottagmessagecozy : BDFDB.disCN.bottagmessagecompact); } } } processAuditLog (instance, wrapper, returnvalue) { let log = BDFDB.ReactUtils.getValue(instance, "props.log"); if (log && log.user) { let hooks = wrapper.querySelectorAll(BDFDB.dotCN.auditloguserhook); let guild_id = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.guildId"); if (hooks.length > 0) this.changeName2(log.user, hooks[0].firstChild, guild_id); if (hooks.length > 1 && log.targetType == "USER") this.changeName2(log.target, hooks[1].firstChild, guild_id); } } processBannedCard (instance, wrapper, returnvalue) { if (instance.props && instance.props.user && instance.props.guild) { let username = wrapper.querySelector(BDFDB.dotCN.guildsettingsbannedusername); if (username) { this.changeName3(instance.props.user, username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); } } } processInviteCard (instance, wrapper, returnvalue) { let invite = BDFDB.ReactUtils.getValue(instance, "props.invite"); if (invite && invite.inviter && invite.guild) { let username = wrapper.querySelector(BDFDB.dotCN.username); if (username) { this.changeName2(invite.inviter, username, invite.guild.id); this.changeAvatar(invite.inviter, this.getAvatarDiv(wrapper)); } } } processMemberCard (instance, wrapper, returnvalue) { if (instance.props && instance.props.user && instance.props.guild) { let username = wrapper.querySelector(BDFDB.dotCN.guildsettingsmembername); if (username) { this.changeName2(instance.props.user, username, instance.props.guild.id); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); } } } processInvitationCard (instance, wrapper, returnvalue) { if (instance.props && instance.props.user) { let username = wrapper.querySelector(BDFDB.dotCN.invitemodalinviterowname); if (username) { this.changeName3(instance.props.user, username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); } } } processTypingUsers (instance, wrapper, returnvalue) { let users = !instance.props.typingUsers ? [] : Object.keys(instance.props.typingUsers).filter(id => id != BDFDB.UserUtils.me.id).filter(id => !BDFDB.LibraryModules.FriendUtils.isBlocked(id)).map(id => BDFDB.LibraryModules.UserStore.getUser(id)).filter(id => id != null); wrapper.querySelectorAll(BDFDB.dotCNS.typing + "strong").forEach((username, i) => { if (users[i] && username) this.changeName2(users[i], username); }); } processDirectMessage (instance, wrapper, returnvalue) { let channel = BDFDB.ReactUtils.getValue(instance, "props.channel"); if (channel && channel.type == 1) { let user = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]); if (user) { let avatar = this.getAvatarDiv(wrapper); if (avatar) { this.changeAvatar(user, avatar); this.changeTooltip(user, avatar, "right"); } } } } processCallAvatar (instance, wrapper, returnvalue) { if (instance.props && instance.props.id) { let user = BDFDB.LibraryModules.UserStore.getUser(instance.props.id); if (!user) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(instance.props.id); if (channel && channel.type == 1) user = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]); } if (user) { this.changeName2(user, wrapper.parentElement.querySelector(BDFDB.dotCN.callmembers)); let avatar = this.getAvatarDiv(wrapper); if (avatar) { this.changeAvatar(user, avatar); if (BDFDB.containsClass(avatar.parentElement, BDFDB.disCN.callvideo)) this.changeTooltip(user, avatar.parentElement, "left"); } } } } processVideoTile (instance, wrapper, returnvalue) { if (instance.props && instance.props.user) this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); } processPictureInPictureVideo (instance, wrapper, returnvalue) { if (instance.props && instance.props.backgroundKey) { let user = BDFDB.LibraryModules.UserStore.getUser(instance.props.backgroundKey); if (user) this.changeAvatar(user, this.getAvatarDiv(wrapper)); } } processPrivateChannel (instance, wrapper, returnvalue) { if (instance.props && instance.props.user) { let username = wrapper.querySelector(BDFDB.dotCN.namecontainername); this.changePrivateChannel(instance.props.user, username && username.firstElementChild ? username.firstElementChild : username); this.changeAvatar(instance.props.user, this.getAvatarDiv(wrapper)); } } processHeaderBarContainer (instance, wrapper, returnvalue) { this.processHeaderBar(instance, wrapper); } processHeaderBar (instance, wrapper, returnvalue) { let channel_id = BDFDB.ReactUtils.getValue(instance, "props.channelId") || BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.channelId"); if (channel_id) { let channelname = wrapper.querySelector(BDFDB.dotCN.channelheaderheaderbartitle); if (channelname) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channel_id); if (channel) { if (channel.type == 1) this.changeName(BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]), channelname); else { if (channelname.EditUsersChangeObserver && typeof channelname.EditUsersChangeObserver.disconnect == "function") channelname.EditUsersChangeObserver.disconnect(); if (BDFDB.BdUtils.isPluginEnabled("EditChannels")) BDFDB.BdUtils.getPlugin("EditChannels").changeChannel(channel, channelname); else { channelname.style.removeProperty("color"); channelname.style.removeProperty("background"); BDFDB.setInnerText(channelname, channel.name); } } } } } } processClickable (instance, wrapper, returnvalue) { if (!wrapper || !instance.props || !instance.props.className) return; if (instance.props.tag == "a" && instance.props.className.indexOf(BDFDB.disCN.anchorunderlineonhover) > -1) { if (BDFDB.containsClass(wrapper.parentElement, BDFDB.disCN.messagesystemcontent) && wrapper.parentElement.querySelector("a") == wrapper) { let message = BDFDB.ReactUtils.findValue(wrapper.parentElement, "message", {up:true}); if (message) { this.changeName(message.author, wrapper); if (message.mentions.length == 1) this.changeName(BDFDB.LibraryModules.UserStore.getUser(message.mentions[0]), wrapper.parentElement.querySelectorAll("a")[1]); } } } else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mention) > -1) { let render = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.stateNode.props.render"); if (typeof render == "function") { var props = render().props; if (props && props.user) this.changeMention(props.user, wrapper); else if (props && props.userId) this.changeMention(BDFDB.LibraryModules.UserStore.getUser(props.userId), wrapper); } } else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) { let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.user"); if (user) { this.changeName2(user, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch)); this.changeAvatar(user, this.getAvatarDiv(wrapper)); } } else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) { let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.user"); if (user) { this.changeName2(user, wrapper.querySelector(BDFDB.dotCN.marginleft8)); this.changeAvatar(user, this.getAvatarDiv(wrapper)); } } else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.searchpopoutuser) > -1) { let result = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.result"); if (result && result.user) { this.changeName3(result.user, wrapper.querySelector(BDFDB.dotCN.searchpopoutdisplayednick)); this.changeAvatar(result.user, wrapper.querySelector(BDFDB.dotCN.searchpopoutdisplayavatar)); } } } processMessageContent (instance, wrapper, returnvalue) { let message = BDFDB.ReactUtils.getValue(instance, "props.message"); if (message && message.author) { let markup = wrapper.querySelector(BDFDB.dotCN.messagemarkup); if (markup) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id) || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, message.author.id) || {}; let data = this.getUserData(message.author.id, wrapper); markup.style.setProperty("color", window.settingsCookie["bda-gs-7"] ? BDFDB.colorCONVERT(data.color1 && !BDFDB.ObjectUtils.is(data.color1) ? data.color1 : member.colorString, "RGBA") : null, "important"); } } } processStandardSidebarView (instance, wrapper, returnvalue) { if (this.SettingsUpdated) { delete this.SettingsUpdated; this.forceUpdateAll(); } } checkUrl (url, instance) { let input = BDFDB.ReactUtils.findDOMNode(instance).firstElementChild; clearTimeout(instance.checkTimeout); if (url == null || !url.trim()) { if (input) BDFDB.removeEles(input.tooltip); instance.props.inputClassName = null; instance.forceUpdate(); } else instance.checkTimeout = setTimeout(() => { BDFDB.LibraryRequires.request(url.trim(), (error, response, result) => { if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1) { if (input) BDFDB.removeEles(input.tooltip); instance.props.inputClassName = BDFDB.disCN.inputsuccess; } else { this.createNoticeTooltip(input, true); instance.props.inputClassName = BDFDB.disCN.inputerror; } delete instance.checkTimeout; instance.forceUpdate(); }); }, 1000); } createNoticeTooltip (input, isinvalid = false) { if (!input) return; BDFDB.removeEles(input.tooltip); var invalid = isinvalid || BDFDB.containsClass(input, BDFDB.disCN.inputerror); var valid = invalid ? false : BDFDB.containsClass(input, BDFDB.disCN.inputsuccess); if (invalid || valid) input.tooltip = BDFDB.TooltipUtils.create(input, invalid ? this.labels.modal_invalidurl_text : this.labels.modal_validurl_text, {type:"right", selector:"notice-tooltip", color: invalid ? "red" : "green"}); } changeAppTitle () { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()); let title = document.head.querySelector("title"); if (title && channel && channel.type == 1) { let info = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]); if (info) { let data = this.getUserData(info.id, title); BDFDB.setInnerText(title, "@" + (data.name || info.username)); } } } changeName (info, username, guildid = BDFDB.LibraryModules.LastGuildStore.getGuildId()) { if (!info || !username || !username.parentElement) return; if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect(); let data = this.getUserData(info.id, username); let member = BDFDB.LibraryModules.MemberStore.getMember(guildid, info.id) || {}; this.changeBotTags(data, username, member); if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) { let isBRCenabled = BDFDB.BdUtils.isPluginEnabled("BetterRoleColors"); let usenick = !BDFDB.containsClass(username, BDFDB.disCN.userprofileusername) && !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname, BDFDB.disCN.accountinfodetails, false) && member.nick; let usemembercolor = !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname) && (BDFDB.containsClass(username, BDFDB.disCN.memberusername, BDFDB.disCN.messageusername, false) || isBRCenabled); if (BDFDB.ObjectUtils.is(data.color1)) { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || (usenick ? member.nick : info.username))}`)); } else { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1 || (usemembercolor ? member.colorString : null), "RGBA"), "important"); BDFDB.setInnerText(username, data.name || (usenick ? member.nick : info.username)); } username.style.setProperty("background", BDFDB.ObjectUtils.is(data.color2) ? BDFDB.colorGRADIENT(data.color2) : BDFDB.colorCONVERT(data.color2, "RGBA"), "important"); if (data.name || data.color1 || data.color2) { username.setAttribute("changed-by-editusers", true); username.EditUsersChangeObserver = new MutationObserver((changes, _) => { username.EditUsersChangeObserver.disconnect(); this.changeName(info, username); }); username.EditUsersChangeObserver.observe(username, {attributes:true}); } else username.removeAttribute("changed-by-editusers"); } } changeName2 (info, username, guildid = BDFDB.LibraryModules.LastGuildStore.getGuildId()) { if (!info || !username || !username.parentElement) return; if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect(); let data = this.getUserData(info.id, username); let member = BDFDB.LibraryModules.MemberStore.getMember(guildid, info.id) || {}; this.changeBotTags(data, username, member); if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) { if (BDFDB.ObjectUtils.is(data.color1)) { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || member.nick || info.username)}`)); } else { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1 || (BDFDB.BdUtils.isPluginEnabled("BetterRoleColors") ? member.colorString : null), "RGBA"), "important"); BDFDB.setInnerText(username, data.name || member.nick || info.username); } if (data.name || data.color1) { username.setAttribute("changed-by-editusers", true); username.EditUsersChangeObserver = new MutationObserver((changes, _) => { username.EditUsersChangeObserver.disconnect(); this.changeName(info, username); }); username.EditUsersChangeObserver.observe(username, {attributes:true}); } else username.removeAttribute("changed-by-editusers"); } } changeName3 (info, username, adddisc = false) { if (!info || !username || !username.parentElement) return; if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect(); let data = this.getUserData(info.id, username); if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) { if (adddisc) { BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || info.username)}#${info.discriminator}`)); } else { if (BDFDB.ObjectUtils.is(data.color1)) { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || info.username)}`)); } else { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1, "RGBA"), "important"); BDFDB.setInnerText(username, data.name || info.username); } } if (data.name || data.color1) { username.setAttribute("changed-by-editusers", true); username.EditUsersChangeObserver = new MutationObserver((changes, _) => { username.EditUsersChangeObserver.disconnect(); this.changeName(info, username); }); username.EditUsersChangeObserver.observe(username, {attributes:true}); } else username.removeAttribute("changed-by-editusers"); } } changeBotTags (data, username, member) { for (let tag of username.parentElement.parentElement.querySelectorAll(BDFDB.dotCN.bottag)) if (!BDFDB.containsClass(tag, "TRE-tag")) { let isBRCbottagsEnabled = BDFDB.ReactUtils.getValue(BDFDB.BdUtils.getPlugin("BetterRoleColors", true), "settings.modules.botTags"); let tagcolor = BDFDB.colorCONVERT(data.color1 || (isBRCbottagsEnabled || BDFDB.containsClass(tag, "owner-tag-rolecolor") ? member.colorString : null), "RGBA"); tagcolor = BDFDB.colorISBRIGHT(tagcolor) ? BDFDB.colorCHANGE(tagcolor, -0.3) : tagcolor; tag.style.setProperty(BDFDB.containsClass(tag, BDFDB.disCN.bottaginvert) ? "color" : "background-color", tagcolor, "important"); } } changeAvatar (info, avatar) { if (!info || !avatar || !avatar.parentElement) return; if (avatar.EditUsersChangeObserver && typeof avatar.EditUsersChangeObserver.disconnect == "function") avatar.EditUsersChangeObserver.disconnect(); let data = this.getUserData(info.id, avatar); if (data.url || data.removeIcon || avatar.getAttribute("changed-by-editusers")) { if (avatar.tagName == "IMG") avatar.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.UserUtils.getAvatar(info.id))); else { let url = data.removeIcon ? null : ("url(" + (data.url || BDFDB.UserUtils.getAvatar(info.id)) + ")"); if (url && BDFDB.getParentEle(BDFDB.dotCN.userprofile, avatar) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)"); avatar.style.setProperty("background-image", url); if (data.url && !data.removeIcon) { avatar.style.setProperty("background-position", "center"); avatar.style.setProperty("background-size", "cover"); } } if (data.url || data.removeIcon) { avatar.setAttribute("changed-by-editusers", true); avatar.EditUsersChangeObserver = new MutationObserver((changes, _) => {changes.forEach((change, i) => { avatar.EditUsersChangeObserver.disconnect(); this.changeAvatar(info, avatar); });}); avatar.EditUsersChangeObserver.observe(avatar, {attributes:true}); } else avatar.removeAttribute("changed-by-editusers"); } } changeTooltip (info, wrapper, type) { if (!info || !wrapper || !wrapper.parentElement) return; let data = this.getUserData(info.id, wrapper); wrapper = BDFDB.containsClass(wrapper, BDFDB.disCN.guildicon) ? wrapper.parentElement.parentElement.parentElement : wrapper; wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditUsers); if (data.name) { wrapper.tooltipListenerEditUsers = () => { BDFDB.TooltipUtils.create(wrapper, data.name, {type, selector:"EditUsers-tooltip", hide:true}); }; wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditUsers); } } addTag (info, wrapper, selector = "", container) { if (!info || !wrapper || !wrapper.parentElement || BDFDB.containsClass(wrapper, BDFDB.disCN.accountinfodetails) || BDFDB.containsClass(wrapper, "discord-tag")) return; BDFDB.removeEles(wrapper.querySelectorAll(".EditUsers-tag")); let data = this.getUserData(info.id, wrapper); if (data.tag) { let member = data.ignoreTagColor ? (BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}) : {}; let color3 = BDFDB.ObjectUtils.is(data.color3) && !data.ignoreTagColor ? BDFDB.colorGRADIENT(data.color3) : BDFDB.colorCONVERT(!data.ignoreTagColor ? data.color3 : member.colorString, "RGBA"); let color4 = BDFDB.ObjectUtils.is(data.color4) && !data.ignoreTagColor ? BDFDB.colorGRADIENT(data.color4) : (!data.ignoreTagColor && data.color4 ? BDFDB.colorCONVERT(data.color4, "RGBA") : (color3 ? (BDFDB.colorISBRIGHT(color3) ? "black" : "white") : null)); let tag = document.createElement("span"); let invert = container && !color3 && !color4 && container.firstElementChild && !(BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userpopoutheadernormal) || BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userprofiletopsectionnormal)); tag.className = "EditUsers-tag " + (!invert ? BDFDB.disCN.bottagregular : BDFDB.disCN.bottaginvert) + (selector ? (" " + selector) : ""); tag.style.setProperty("background", !invert ? color3 : color4, "important"); let fontcolor = invert ? color3 : color4; let fontobj = invert ? data.color3 : data.color4; if (BDFDB.ObjectUtils.is(fontobj)) tag.appendChild(BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.tag)}`)); else { tag.innerText = data.tag; tag.style.setProperty("color", fontcolor, "important"); } wrapper.appendChild(tag); } } changePrivateChannel (info, username) { if (!info || !username || !username.parentElement) return; let dmchannel = BDFDB.getParentEle(BDFDB.dotCN.dmchannel, username); if (!dmchannel) return; if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect(); dmchannel.removeEventListener("mouseenter", dmchannel.mouseenterListenerEditUsers); dmchannel.removeEventListener("mouseleave", dmchannel.mouseleaveListenerEditUsers); let data = this.getUserData(info.id, username); if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) { if (username.EditUsersHovered || BDFDB.containsClass(dmchannel, BDFDB.disCN.namecontainerselected)) colorHover(); else colorDefault(); if (data.name || data.color1 || data.color2) { dmchannel.mouseenterListenerEditUsers = () => { username.EditUsersHovered = true; colorHover(); }; dmchannel.mouseleaveListenerEditUsers = () => { delete username.EditUsersHovered; colorDefault(); }; dmchannel.addEventListener("mouseenter", dmchannel.mouseenterListenerEditUsers); dmchannel.addEventListener("mouseleave", dmchannel.mouseleaveListenerEditUsers); username.setAttribute("changed-by-editusers", true); username.EditUsersChangeObserver = new MutationObserver((changes, _) => { username.EditUsersChangeObserver.disconnect(); this.changePrivateChannel(info, username); }); username.EditUsersChangeObserver.observe(username, {attributes:true}); } else username.removeAttribute("changed-by-editusers"); function colorDefault() { if (BDFDB.ObjectUtils.is(data.color1)) { username.style.removeProperty("color"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || info.username)}`)); } else { username.style.setProperty("color", BDFDB.colorCHANGE(data.color1, -0.5, "RGBA"), "important"); BDFDB.setInnerText(username, data.name || info.username); } username.style.setProperty("background", BDFDB.ObjectUtils.is(data.color2) ? BDFDB.colorGRADIENT(BDFDB.colorCHANGE(data.color2, -0.5)) : BDFDB.colorCHANGE(data.color2, -0.5, "RGBA"), "important"); } function colorHover() { if (BDFDB.ObjectUtils.is(data.color1)) { username.style.removeProperty("color"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || info.username)}`)); } else { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1, "RGBA"), "important"); BDFDB.setInnerText(username, data.name || info.username); } username.style.setProperty("background", BDFDB.ObjectUtils.is(data.color2) ? BDFDB.colorGRADIENT(data.color2) : BDFDB.colorCONVERT(data.color2, "RGBA"), "important"); } } } changeMention (info, mention) { if (!info || !mention || !mention.parentElement) return; if (mention.EditUsersChangeObserver && typeof mention.EditUsersChangeObserver.disconnect == "function") mention.EditUsersChangeObserver.disconnect(); mention.removeEventListener("mouseover", mention.mouseoverListenerEditUsers); mention.removeEventListener("mouseout", mention.mouseoutListenerEditUsers); let data = this.getUserData(info.id, mention); let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}; let name = "@" + (data.name ? data.name : (BDFDB.BdUtils.isPluginEnabled("RemoveNicknames") ? BDFDB.BdUtils.getPlugin("RemoveNicknames").getNewName(info, mention) : member.nick || info.username)); let isgradient = data.color1 && BDFDB.ObjectUtils.is(data.color1); let datacolor = data.color1 || (BDFDB.BdUtils.isPluginEnabled("BetterRoleColors") ? member.colorString : null); let color = isgradient ? BDFDB.colorGRADIENT(data.color1) : BDFDB.colorCONVERT(datacolor, "RGBA"); let color0_1 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color1, 0.1, "RGBA")) : BDFDB.colorSETALPHA(datacolor, 0.1, "RGBA"); let color0_7 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color1, 0.7, "RGBA")) : BDFDB.colorSETALPHA(datacolor, 0.7, "RGBA"); if (mention.EditUsersHovered) colorHover(); else colorDefault(); mention.mouseoverListenerEditUsers = () => { mention.EditUsersHovered = true; colorHover(); }; mention.mouseoutListenerEditUsers = () => { delete mention.EditUsersHovered; colorDefault(); }; mention.addEventListener("mouseover", mention.mouseoverListenerEditUsers); mention.addEventListener("mouseout", mention.mouseoutListenerEditUsers); mention.EditUsersChangeObserver = new MutationObserver((changes, _) => { mention.EditUsersChangeObserver.disconnect(); this.changeMention(info, mention); }); mention.EditUsersChangeObserver.observe(mention, {attributes:true}); function colorDefault() { mention.style.setProperty("background", color0_1, "important"); if (isgradient) { mention.style.removeProperty("color"); BDFDB.setInnerText(mention, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(name)}`)); } else { mention.style.setProperty("color", color, "important"); BDFDB.setInnerText(mention, name); } } function colorHover() { mention.style.setProperty("background", color0_7, "important"); mention.style.setProperty("color", data.color1 ? "#FFFFFF" : null, "important"); BDFDB.setInnerText(mention, name); } } changeVoiceUser (info, username, speaking) { if (!info || !username || !username.parentElement) return; if (username.EditUsersChangeObserver && typeof username.EditUsersChangeObserver.disconnect == "function") username.EditUsersChangeObserver.disconnect(); username.removeEventListener("mouseover", username.mouseoverListenerEditUsers); username.removeEventListener("mouseout", username.mouseoutListenerEditUsers); let data = this.getUserData(info.id, username); if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) { let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}; if (username.EditUsersHovered) colorHover(); else colorDefault(); if (data.name || data.color1) { username.mouseoverListenerEditUsers = () => { username.EditUsersHovered = true; colorHover(); }; username.mouseoutListenerEditUsers = () => { delete username.EditUsersHovered; colorDefault(); }; username.parentElement.parentElement.addEventListener("mouseover", username.mouseoverListenerEditUsers); username.parentElement.parentElement.addEventListener("mouseout", username.mouseoutListenerEditUsers); username.EditUsersChangeObserver = new MutationObserver((changes, _) => { username.EditUsersChangeObserver.disconnect(); this.changeVoiceUser(info, username, speaking); }); username.EditUsersChangeObserver.observe(username, {attributes:true}); } else username.removeAttribute("changed-by-editusers"); function colorDefault() { if (BDFDB.ObjectUtils.is(data.color1)) { username.style.removeProperty("color"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || member.nick || info.username)}`)); } else { var color1 = data.color1 || (BDFDB.BdUtils.isPluginEnabled("BetterRoleColors") ? member.colorString : ""); username.style.setProperty("color", !speaking ? BDFDB.colorCHANGE(color1, -50, "RGBA") : BDFDB.colorCONVERT(color1, "RGBA"), "important"); BDFDB.setInnerText(username, data.name || member.nick || info.username); } } function colorHover() { if (BDFDB.ObjectUtils.is(data.color1)) { username.style.removeProperty("color"); BDFDB.setInnerText(username, BDFDB.htmlToElement(`${BDFDB.encodeToHTML(data.name || member.nick || info.username)}`)); } else { username.style.setProperty("color", BDFDB.colorCONVERT(data.color1, "RGBA"), "important"); BDFDB.setInnerText(username, data.name || member.nick || info.username); } } } } getAvatarDiv (wrapper) { var avatar = wrapper.querySelector(this.avatarselector); while (!avatar && wrapper.parentElement) { wrapper = wrapper.parentElement; avatar = wrapper.querySelector(this.avatarselector); } return avatar.querySelector("img") || avatar.firstElementChild || avatar; } getUserData (id, wrapper) { let data = BDFDB.loadData(id, this, "users"); if (!data) { delete wrapper.EditUsersCachedDataState; return {}; } else if (wrapper.EditUsersCachedDataState) { return data; } let allenabled = true, settings = BDFDB.getAllData(this, "settings"); for (let i in settings) if (!settings[i]) { allenabled = false; break; } if (allenabled) return data; let key = null; if (!BDFDB.containsClass(wrapper, BDFDB.disCN.mention) && BDFDB.getParentEle(BDFDB.dotCN.messagegroup, wrapper)) key = "changeInChatWindow"; else if (BDFDB.containsClass(wrapper, BDFDB.disCN.mention)) key = "changeInMentions"; else if (BDFDB.getParentEle(BDFDB.dotCN.textareawrapchat, wrapper)) key = "changeInChatTextarea"; else if (BDFDB.getParentEle(BDFDB.dotCN.voiceuser, wrapper)) key = "changeInVoiceChat"; else if (BDFDB.getParentEle(BDFDB.dotCN.members, wrapper)) key = "changeInMemberList"; else if (BDFDB.getParentEle(BDFDB.dotCN.guildouter, wrapper)) key = "changeInRecentDms"; else if (BDFDB.getParentEle(BDFDB.dotCN.dmchannels, wrapper)) key = "changeInDmsList"; else if (BDFDB.getParentEle(BDFDB.dotCN.channelheaderheaderbar, wrapper)) key = "changeInDmHeader"; else if (BDFDB.getParentEle(BDFDB.dotCN.callavatarwrapper, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.callincoming, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.callcurrentcontainer, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.pictureinpicture, wrapper)) key = "changeInDmCalls"; else if (BDFDB.getParentEle(BDFDB.dotCN.typing, wrapper)) key = "changeInTyping"; else if (BDFDB.getParentEle(BDFDB.dotCN.friends, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.userprofilebody, wrapper)) key = "changeInFriendList"; else if (BDFDB.getParentEle(BDFDB.dotCN.invitemodalinviterow, wrapper)) key = "changeInInviteList"; else if (BDFDB.getParentEle(BDFDB.dotCN.activityfeed, wrapper)) key = "changeInActivity"; else if (BDFDB.getParentEle(BDFDB.dotCN.userpopout, wrapper)) key = "changeInUserPopout"; else if (BDFDB.getParentEle(BDFDB.dotCN.userprofileheader, wrapper)) key = "changeInUserProfil"; else if (BDFDB.getParentEle(BDFDB.dotCN.autocomplete, wrapper)) key = "changeInAutoComplete"; else if (BDFDB.getParentEle(BDFDB.dotCN.auditlog, wrapper)) key = "changeInAuditLog"; else if (BDFDB.getParentEle(BDFDB.dotCN.guildsettingsbannedcard, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.guildsettingsinvitecard, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.guildsettingsmembercard, wrapper)) key = "changeInMemberLog"; else if (BDFDB.getParentEle(BDFDB.dotCN.searchpopout, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.searchpopoutdmaddpopout, wrapper) || BDFDB.getParentEle(BDFDB.dotCN.quickswitcher, wrapper)) key = "changeInSearchPopout"; else if (BDFDB.getParentEle(BDFDB.dotCN.accountinfo, wrapper)) key = "changeInUserAccount"; else if (wrapper.parentElement == document.head) key = "changeInAppTitle"; if (!key || settings[key]) { wrapper.EditUsersCachedDataState = true; return data; } else return {}; } addAutoCompleteMenu (textarea, channel) { if (textarea.parentElement.querySelector(".autocompleteEditUsersRow")) return; let words = textarea.value.split(/\s/); let lastword = words[words.length-1].trim(); if (lastword && lastword.length > 1 && lastword[0] == "@") { let users = BDFDB.loadAllData(this, "users"); if (!users) return; let userarray = []; for (let id in users) if (users[id].name) { let user = BDFDB.LibraryModules.UserStore.getUser(id); let member = user ? BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, id) : null; if (user && member) userarray.push(Object.assign({lowercasename:users[id].name.toLowerCase(),user,member},users[id])); } userarray = BDFDB.ArrayUtils.keySort(userarray.filter(n => n.lowercasename.indexOf(lastword.toLowerCase().slice(1)) != -1), "lowercasename"); if (userarray.length) { let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15; if (!autocompletemenu) { autocompletemenu = BDFDB.htmlToElement(`