Fix colored text for stable (#530)

* Fix colored text for stable

* that didn't happen...

* fix typo
This commit is contained in:
Strencher 2021-01-09 04:28:33 +01:00 committed by GitHub
parent 3780a0bd41
commit f83e053565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -2,6 +2,9 @@ import {settingsCookie} from "../0globals";
import BDV2 from "./v2";
import Utils from "./utils";
const ChannelStore = BDV2.WebpackModules.findByUniqueProperties(["getChannel", "getGuildChannels"]);
const GuildMemberStore = BDV2.WebpackModules.findByUniqueProperties(["getMember"]);
export default new class ColoredText {
injectColoredText() {
if (this.cancelColoredText) return;
@ -15,9 +18,10 @@ export default new class ColoredText {
if (!messageContent.type || !messageContent.type.type || messageContent.type.type.displayName != "MessageContent") return;
const originalType = messageContent.type.type;
if (originalType.__originalMethod) return; // Don't patch again
const self = this;
messageContent.type.type = function(props) {
const returnValue = originalType(props);
const roleColor = settingsCookie["bda-gs-7"] ? props.message.colorString || "" : "";
const roleColor = settingsCookie["bda-gs-7"] ? self.getRoleColor(props.message.channel_id, props.message.author.id) || "" : "";
returnValue.props.style = {color: roleColor};
return returnValue;
};
@ -27,9 +31,17 @@ export default new class ColoredText {
}});
}
getRoleColor(channelId, memberId) {
const channel = ChannelStore.getChannel(channelId);
if (!channel) return "";
const member = GuildMemberStore.getMember(channel.guild_id, memberId);
if (!member) return "";
return member.colorString;
}
removeColoredText() {
document.querySelectorAll(".markup-2BOw-j").forEach(elem => {
elem.style.setProperty("color", "");
});
}
};
};