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