Plugin

Anammox

A microbial process that plays an important part in the nitrogen cycle

index.ts
Download

Source

src/plugins/annamox/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 definePlugin, { OptionType } from "@utils/types";
10
11export const settings = definePluginSettings({
12 dms: {
13 type: OptionType.BOOLEAN,
14 default: true,
15 description: "Remove shops above DMs list",
16 restartNeeded: true,
17 },
18 billing: {
19 type: OptionType.BOOLEAN,
20 default: true,
21 description: "Remove billing settings",
22 restartNeeded: true,
23 },
24 gift: {
25 type: OptionType.BOOLEAN,
26 default: true,
27 description: "Remove gift button",
28 restartNeeded: true,
29 },
30 emojiList: {
31 type: OptionType.BOOLEAN,
32 default: true,
33 description: "Remove unavailable categories from the emoji picker",
34 restartNeeded: true,
35 },
36});
37
38export default definePlugin({
39 name: "Anammox",
40 description: "A microbial process that plays an important part in the nitrogen cycle",
41 authors: [Devs.FiveCord],
42 settings,
43
44 patches: [
45 { class="ts-cmt">// Above DMs, mouse nav
46 find: 'tutorialId:"direct-messages"',
47 replacement: [
48 {
49 match: /"premium"\)/,
50 replace: "$&&&undefined",
51 },
52 {
53 match: /"discord-shop"\)/,
54 replace: "$&&&undefined",
55 },
56 ],
57 predicate: () => settings.store.dms,
58 },
59 { class="ts-cmt">// Above DMs, keyboard nav
60 find: ".default.hasLibraryApplication()&&!",
61 replacement: [
62 {
63 match: /\i\.Routes\.APPLICATION_STORE,/,
64 replace: "/*$&*/",
65 },
66 {
67 match: /\i\.Routes\.COLLECTIBLES_SHOP,/,
68 replace: "/*$&*/",
69 },
70 ],
71 predicate: () => settings.store.dms,
72 },
73 { class="ts-cmt">// Settings, sidebar
74 find: "Messages.BILLING_SETTINGS",
75 replacement: {
76 match: /\{section:\i\.SectionTypes\.HEADER,label:\i\.default\.Messages\.BILLING_SETTINGS\},.*?\{section:\i\.SectionTypes\.DIVIDER\},/,
77 replace: "/*$&*/"
78 },
79 predicate: () => settings.store.billing,
80 },
81 { class="ts-cmt">// Gift button
82 find: 'Messages.PREMIUM_GIFT_BUTTON_LABEL,"aria-haspopup":"dialog",onClick:',
83 replacement: {
84 match: /if\(\w+\)return null;/,
85 replace: "return null;",
86 },
87 predicate: () => settings.store.gift,
88 },
89 { class="ts-cmt">// Emoji list
90 find: "useEmojiGrid:function()",
91 replacement: {
92 match: /(\w+)=!\w+&&\w+.default.isEmojiCategoryNitroLocked\(\{[^}]*\}\);/,
93 replace: "$&$1||"
94 },
95 predicate: () => settings.store.emojiList,
96 },
97 { class="ts-cmt">// Emoji category list
98 find: ".Messages.EMOJI_PICKER_SCROLL_TO_UNICODE_A11Y_LABEL",
99 replacement: {
100 match: /(\w+)=\(0,\w+.useCategoryNitroLockedStates\)\(\w+,\w+,(\w+)\)/,
101 replace: "$&,__98=($2=$2.filter((_,$2)=>!$1[$2]))"
102 },
103 predicate: () => settings.store.emojiList,
104 }
105 ],
106});
107