From 4c4036546a989023c7c0f1ee8f4b36d84f82becd Mon Sep 17 00:00:00 2001 From: bb010g Date: Fri, 18 Aug 2023 16:10:59 -0700 Subject: new plugin: NormalizeMessageLinks (#1641) --- src/plugins/normalizeMessageLinks/index.ts | 26 ++++++++++++++++++++++++++ src/utils/constants.ts | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 src/plugins/normalizeMessageLinks/index.ts diff --git a/src/plugins/normalizeMessageLinks/index.ts b/src/plugins/normalizeMessageLinks/index.ts new file mode 100644 index 0000000..cac36e6 --- /dev/null +++ b/src/plugins/normalizeMessageLinks/index.ts @@ -0,0 +1,26 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "NormalizeMessageLinks", + description: "Strip canary/ptb from message links", + authors: [Devs.bb010g], + patches: [ + { + find: ".Messages.COPY_MESSAGE_LINK,", + replacement: { + match: /\.concat\(location\.host\)/, + replace: ".concat($self.normalizeHost(location.host))", + }, + }, + ], + normalizeHost(host: string) { + return host.replace(/(^|\b)(canary\.|ptb\.)(discord.com)$/, "$1$3"); + }, +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 3266e24..9e2b2fe 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -347,6 +347,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "arrow", id: 958158495302176778n }, + bb010g: { + name: "bb010g", + id: 72791153467990016n, + }, } satisfies Record); // iife so #__PURE__ works correctly -- cgit