From 0944c0708fbcae8b7de9758d44b98aee3e856f2e Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Fri, 27 Apr 2018 15:53:49 +0100 Subject: [PATCH] Add user profile modal data attributes --- client/src/modules/reactcomponents.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index 692f94dc..412767c4 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -298,6 +298,7 @@ export class ReactAutoPatcher { await this.patchGuild(); await this.patchChannel(); await this.patchChannelList(); + await this.patchUserProfileModal(); this.forceUpdate(); } @@ -367,6 +368,17 @@ export class ReactAutoPatcher { }); } + static async patchUserProfileModal() { + this.UserProfileModal = await ReactComponents.getComponent('UserProfileModal', { selector: '.root-2sNHUF' }, Filters.byPrototypeFields(['renderHeader', 'renderBadges'])); + this.unpatchUserProfileModal = MonkeyPatch('BD:ReactComponents', this.UserProfileModal.component.prototype).after('render', (component, args, retVal) => { + const { user } = component.props; + if (!user) return; + retVal.props['data-user-id'] = user.id; + if (user.bot) retVal.props.className += ' bd-isBot'; + if (user.id === DiscordApi.currentUser.id) retVal.props.className += ' bd-isCurrentUser'; + }); + } + static forceUpdate() { for (const e of document.querySelectorAll('.message, .message-group, .guild, .containerDefault-7RImuF, .channel-members .member-2FrNV0')) { Reflection(e).forceUpdate();