new plugin: NormalizeMessageLinks (#1641)

This commit is contained in:
bb010g 2023-08-18 16:10:59 -07:00 committed by GitHub
parent d582e61ec3
commit 4c4036546a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -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");
},
});

View File

@ -347,6 +347,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "arrow",
id: 958158495302176778n
},
bb010g: {
name: "bb010g",
id: 72791153467990016n,
},
} satisfies Record<string, Dev>);
// iife so #__PURE__ works correctly