From a0e7398725b70e3c0e0364a3eb773915f3548639 Mon Sep 17 00:00:00 2001 From: Grzesiek11 Date: Sun, 17 Dec 2023 13:20:49 +0100 Subject: [PATCH] Add TextEmoji plugin The plugin prevents Discord from replacing emoji with images, leaving it up to the browser to render them. --- src/plugins/textEmoji/index.ts | 42 ++++++++++++++++++++++++++++++++++ src/utils/constants.ts | 4 ++++ 2 files changed, 46 insertions(+) create mode 100644 src/plugins/textEmoji/index.ts diff --git a/src/plugins/textEmoji/index.ts b/src/plugins/textEmoji/index.ts new file mode 100644 index 000000000..7e8da3b8f --- /dev/null +++ b/src/plugins/textEmoji/index.ts @@ -0,0 +1,42 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 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 { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "TextEmoji", + description: "Prevents Discord from replacing emoji with images, leaving it up to the browser to render them", + authors: [Devs.Grzesiek11], + patches: [ + { + find: "getSrc(){", + replacement: { + match: /(if\(null!=.{1,2}\))return .{1,2}\.default\.getURL\(.{1,2}\)/, + replace: "$1return null", + }, + }, + { + find: ",findInlineEmojisFromSurrogates:", + replacement: { + match: /if\(!0!==.{1,2}&&!.{1,2}\.test\(.{1,2}\)\)/, + replace: "", + }, + }, + ], +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 2962df06f..a94ba0fc3 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -399,6 +399,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "maisy", id: 257109471589957632n, }, + Grzesiek11: { + name: "Grzesiek11", + id: 368475654662127616n, + }, } satisfies Record); // iife so #__PURE__ works correctly