Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RCE): headers are not affected with colored text #3036

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions src/plugins/roleColorEverywhere/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default definePlugin({
find: "#{intl::MESSAGE_EDITED}",
replacement: {
match: /(?<=isUnsupported\]:(\i)\.isUnsupported\}\),)(?=children:\[)/,
replace: "style:$self.useMessageColorStyle($1),"
replace: "style:$self.useMessageColors($1),"
},
predicate: () => settings.store.colorChatMessages
}
Expand Down Expand Up @@ -188,13 +188,19 @@ export default definePlugin({
};
},

useMessageColor(message: any) {
useMessageColors(message: any) {
try {
const { messageSaturation } = settings.use(["messageSaturation"]);
const author = useMessageAuthor(message);

if (author.colorString != null && messageSaturation !== 0) {
return `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var(--text-normal))`;
const value = `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var({DEFAULT}))`;

return {
color: value.replace("{DEFAULT}", "--text-normal"),
"--header-primary": value.replace("{DEFAULT}", "--header-primary"),
"--text-muted": value.replace("{DEFAULT}", "--text-muted")
};
}
} catch (e) {
new Logger("RoleColorEverywhere").error("Failed to get message color", e);
Expand All @@ -203,14 +209,6 @@ export default definePlugin({
return null;
},

useMessageColorStyle(message: any) {
const color = this.useMessageColor(message);

return color && {
color
};
},

RoleGroupColor: ErrorBoundary.wrap(({ id, count, title, guildId, label }: { id: string; count: number; title: string; guildId: string; label: string; }) => {
const role = GuildStore.getRole(guildId, id);

Expand Down