Plugin

NoPendingCount

Removes the ping count of incoming friend requests, message requests, and nitro offers.

Notifications Appearance
index.ts
Download

Source

src/plugins/noPendingCount/index.ts
1import { definePluginSettings } from "@api/Settings";
2import { Devs } from "@utils/constants";
3import definePlugin, { OptionType } from "@utils/types";
4import { findByPropsLazy } from "@webpack";
5
6const MessageRequestStore = findByPropsLazy("getMessageRequestsCount");
7
8const settings = definePluginSettings({
9 hideFriendRequestsCount: {
10 type: OptionType.BOOLEAN,
11 description: "Hide incoming friend requests count",
12 default: true,
13 restartNeeded: true
14 },
15 hideMessageRequestsCount: {
16 type: OptionType.BOOLEAN,
17 description: "Hide message requests count",
18 default: true,
19 restartNeeded: true
20 },
21 hidePremiumOffersCount: {
22 type: OptionType.BOOLEAN,
23 description: "Hide nitro offers count",
24 default: true,
25 restartNeeded: true
26 }
27});
28
29export default definePlugin({
30 name: "NoPendingCount",
31 description: "Removes the ping count of incoming friend requests, message requests, and nitro offers.",
32 tags: ["Notifications", "Appearance"],
33 authors: [Devs.amia],
34
35 settings: settings,
36
37 // Functions used to determine the top left count indicator can be found in the single module that calls getUnacknowledgedOffers(...)
38 // or by searching for "showProgressBadge:"
39 patches: [
40 {
41 find: "getPendingCount(){",
42 predicate: () => settings.store.hideFriendRequestsCount,
43 replacement: {
44 match: /(?<=getPendingCount\(\)\{)/,
45 replace: "return 0;"
46 }
47 },
48 // Message requests hook
49 {
50 find: "getMessageRequestsCount(){",
51 predicate: () => settings.store.hideMessageRequestsCount,
52 replacement: {
53 match: /(?<=getMessageRequestsCount\(\)\{)/,
54 replace: "return 0;"
55 }
56 },
57 // This prevents the Message Requests tab from always hiding due to the previous patch (and is compatible with spam requests)
58 // In short, only the red badge is hidden. Button visibility behavior isn't changed.
59 {
60 find: ".getSpamChannelsCount();return",
61 predicate: () => settings.store.hideMessageRequestsCount,
62 replacement: {
63 match: /(?<=getSpamChannelsCount\(\);return )\i\.getMessageRequestsCount\(\)/,
64 replace: "$self.getRealMessageRequestCount()"
65 }
66 },
67 {
68 find: "showProgressBadge:",
69 predicate: () => settings.store.hidePremiumOffersCount,
70 replacement: {
71 // The two groups inside the first group grab the minified names of the variables,
72 // they are then referenced later to find unviewedTrialCount + unviewedDiscountCount.
73 match: /(\{unviewedTrialCount:(\i),unviewedDiscountCount:(\i)\}.+?)\2\+\3/,
74 replace: (_, rest) => `${rest}0`
75 }
76 }
77 ],
78
79 getRealMessageRequestCount() {
80 return MessageRequestStore.getMessageRequestChannelIds().size;
81 }
82});
83