commit cd41d28f66f3a7a71746ad16d1033d305d9ba0d9 Author: slonkazoid Date: Sun Dec 15 16:35:32 2024 +0300 initial commit diff --git a/notificationContent/index.tsx b/notificationContent/index.tsx new file mode 100644 index 0000000..f08ff68 --- /dev/null +++ b/notificationContent/index.tsx @@ -0,0 +1,72 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import { definePluginSettings } from "@api/Settings"; +import definePlugin, { OptionType } from "@utils/types"; + +const settings = definePluginSettings({ + mode: { + description: "Content to show", + type: OptionType.SELECT, + options: [ + { + label: "Name and content", + value: 0, + default: true, + }, + { + label: "Name only", + value: 1, + }, + { + label: "No name or content", + value: 2, + }, + ], + }, +}); + +export default definePlugin({ + name: "NotificationContent", + description: "Customize notification content", + authors: [{ name: "slonkazoid", id: 276363003270791168n }], + settings, + + process( + icon: string, + title: string, + body: string + ): { icon?: string; title: string; body: string } { + return { + icon: settings.store.mode !== 2 ? icon : undefined, + title: settings.store.mode !== 2 ? title : "Discord", + body: settings.store.mode === 0 ? body : "New message", + }; + }, + + patches: [ + { + find: "showNotification:function", + replacement: { + match: /(showNotification:function\((\i),(\i),(\i),\i,\i\){)/, + replace: + "$1let processed = $self.process($2, $3, $4); $2 = processed.icon; $3 = processed.title; $4 = processed.body;", + }, + }, + ], +});