Plugin

ColorMessage

Colors message content with author's role color

index.ts
Download

Source

src/plugins/colorMessage/index.ts
1/*
2 * FiveCord — a Discord client mod
3 * Copyright (c) 2025 FiveCord
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7import { definePluginSettings } from "@api/Settings";
8import * as Styles from "@api/Styles";
9import { Devs } from "@utils/constants";
10import definePlugin, { makeRange, OptionType } from "@utils/types";
11import { findByPropsLazy } from "@webpack";
12
13const AuthorStore = findByPropsLazy("useNullableMessageAuthor", "useNullableMessageAuthor");
14
15import style from "./style.css?managed";
16
17export const settings = definePluginSettings({
18 saturation: {
19 type: OptionType.SLIDER,
20 description: "Message color saturation",
21 markers: makeRange(0, 100, 10),
22 default: 20,
23 onChange() {
24 updateStyle();
25 },
26 },
27});
28
29function updateStyle() {
30 (Styles.requireStyle(style).dom!.sheet!.cssRules[0] as CSSStyleRule)
31 .style.setProperty("--98-message-color-saturation", `${settings.store.saturation}`);
32}
33
34export default definePlugin({
35 name: "ColorMessage",
36 description: "Colors message content with author's role color",
37 authors: [Devs.FiveCord],
38 settings,
39
40 patches: [
41 {
42 find: 'default.Messages.MESSAGE_EDITED,")"',
43 replacement: {
44 match: /id:\(0,\w+.getMessageContentId\)\((\w+)\),/,
45 replace: '$&style:{"--98-message-color":$self.getMessageColor($1)},'
46 }
47 },
48 ],
49
50 getMessageColor(messageId: string) {
51 return AuthorStore.default(messageId).colorString;
52 },
53
54 start() {
55 Styles.enableStyle(style);
56 updateStyle();
57 },
58 stop() {
59 Styles.disableStyle(style);
60 },
61});
62