diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2022-10-23 14:19:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-23 14:19:53 +0200 |
commit | 50c0d472d7f75e22a6097ef03a7d71129a5f3f96 (patch) | |
tree | c2ba933fd832c0586ae55af59811db288d2a0148 /src/plugins/noCanaryMessageLinks.ts | |
parent | abbc08fb06df0ab9fcb8b30e42d52cad851025c2 (diff) | |
download | Vencord-50c0d472d7f75e22a6097ef03a7d71129a5f3f96.tar.gz Vencord-50c0d472d7f75e22a6097ef03a7d71129a5f3f96.tar.bz2 Vencord-50c0d472d7f75e22a6097ef03a7d71129a5f3f96.zip |
feat(NoCanaryMessageLinks): Allow custom subdomains (#147)
Diffstat (limited to 'src/plugins/noCanaryMessageLinks.ts')
-rw-r--r-- | src/plugins/noCanaryMessageLinks.ts | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/plugins/noCanaryMessageLinks.ts b/src/plugins/noCanaryMessageLinks.ts index 3ee95cd..b93562c 100644 --- a/src/plugins/noCanaryMessageLinks.ts +++ b/src/plugins/noCanaryMessageLinks.ts @@ -18,16 +18,38 @@ import { addPreSendListener, MessageObject, removePreSendListener } from "../api/MessageEvents"; import { Devs } from "../utils/constants"; -import definePlugin from "../utils/types"; +import definePlugin, { OptionType } from "../utils/types"; +import { Settings } from "../Vencord"; export default definePlugin({ name: "NoCanaryMessageLinks", - description: "Removes the canary and ptb prefix from message links", - authors: [Devs.Samu], + description: "Allows you to change/remove the subdomain of discord message and channel links", + authors: [ + Devs.Samu, + Devs.nea, + ], + options: { + linkPrefix: { + description: "The subdomain for your discord message links", + type: OptionType.STRING, + default: "", + restartNeeded: false, + }, + alwaysUseDiscordHost: { + description: "Always use discord.com host (replace discordapp.com)", + type: OptionType.BOOLEAN, + default: false, + restartNeeded: false, + }, + }, dependencies: ["MessageEventsAPI"], removeBetas(msg: MessageObject) { - msg.content = msg.content.replace(/(?<=https:\/\/)(canary.|ptb.)(?=discord(?:app)?.com\/channels\/(?:\d{17,20}|@me)\/\d{17,20}\/\d{17,20})/g, ""); // Ven W + const settings = Settings.plugins.NoCanaryMessageLinks; + msg.content = msg.content.replace( + /https:\/\/(?:canary\.|ptb\.)?(discord(?:app)?\.com)(\/channels\/(?:\d{17,20}|@me)\/\d{17,20}(?:\/\d{17,20})?)/g, + (_, host, path) => "https://" + (settings.linkPrefix ? settings.linkPrefix + "." : "") + (settings.alwaysUseDiscordHost ? "discord.com" : host) + path + ); }, start() { |