Plugin

BetterRoleDot

Copy role colour on RoleDot (accessibility setting) click. Also allows using both RoleDot and coloured names simultaneously

Roles Appearance
index.ts
Download

Source

src/plugins/betterRoleDot/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 { Devs } from "@utils/constants";
9import { copyWithToast } from "@utils/discord";
10import definePlugin, { OptionType } from "@utils/types";
11
12const settings = definePluginSettings({
13 bothStyles: {
14 type: OptionType.BOOLEAN,
15 description: "Show both role dot and coloured names",
16 restartNeeded: true,
17 default: false,
18 },
19 copyRoleColorInProfilePopout: {
20 type: OptionType.BOOLEAN,
21 description: "Allow click on role dot in profile popout to copy role color",
22 restartNeeded: true,
23 default: false
24 }
25});
26
27export default definePlugin({
28 name: "BetterRoleDot",
29 authors: [Devs.Ven, Devs.AutumnVN],
30 description:
31 "Copy role colour on RoleDot (accessibility setting) click. Also allows using both RoleDot and coloured names simultaneously",
32 tags: ["Roles", "Appearance"],
33 settings,
34
35 patches: [
36 {
37 // Class used in this module is dotBorderBase
38 find: "M0 4C0 1.79086 1.79086 0 4 0H16C18.2091 0 20 1.79086 20 4V16C20 18.2091 18.2091 20 16 20H4C1.79086 20 0 18.2091 0 16V4Z",
39 replacement: {
40 match: /,viewBox:"0 0 20 20"/,
41 replace: "$&,onClick:()=>$self.copyToClipBoard(arguments[0].color),style:{cursor:'pointer'}",
42 },
43 },
44 {
45 find: '"dot"===',
46 all: true,
47 noWarn: true,
48 predicate: () => settings.store.bothStyles,
49 replacement: {
50 match: /"(?:username|dot)"===\i(?!\.\i)/g,
51 replace: "true",
52 },
53 },
54
55 {
56 find: "#{intl::ADD_ROLE_A11Y_LABEL}",
57 all: true,
58 predicate: () => settings.store.copyRoleColorInProfilePopout && !settings.store.bothStyles,
59 noWarn: true,
60 replacement: {
61 match: /"dot"===\i/,
62 replace: "true"
63 }
64 },
65 {
66 find: ".roleVerifiedIcon",
67 all: true,
68 predicate: () => settings.store.copyRoleColorInProfilePopout && !settings.store.bothStyles,
69 noWarn: true,
70 replacement: {
71 match: /"dot"===\i/,
72 replace: "true"
73 }
74 }
75 ],
76
77 copyToClipBoard(color: string) {
78 copyWithToast(color);
79 },
80});
81