From 1317222c35a4f6dd2b7329507c7b7ac5a9854d9e Mon Sep 17 00:00:00 2001 From: puv Date: Wed, 8 May 2024 04:44:57 +0300 Subject: [PATCH] feat(plugin): VoiceDownload (#2280) Co-authored-by: vee --- src/plugins/voiceDownload/index.tsx | 53 +++++++++++++++++++++++++++++ src/plugins/voiceDownload/style.css | 12 +++++++ src/utils/constants.ts | 4 +++ 3 files changed, 69 insertions(+) create mode 100644 src/plugins/voiceDownload/index.tsx create mode 100644 src/plugins/voiceDownload/style.css diff --git a/src/plugins/voiceDownload/index.tsx b/src/plugins/voiceDownload/index.tsx new file mode 100644 index 000000000..453a522d3 --- /dev/null +++ b/src/plugins/voiceDownload/index.tsx @@ -0,0 +1,53 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./style.css"; + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "VoiceDownload", + description: "Adds a download to voice messages. (Opens a new browser tab)", + authors: [Devs.puv], + patches: [ + { + find: "rippleContainer,children", + replacement: { + match: /\(0,\i\.jsx\).{0,150},children:.{0,50}\("source",{src:(\i)}\)}\)/, + replace: "[$&, $self.renderDownload($1)]" + } + } + ], + + renderDownload(src: string) { + return ( + e.stopPropagation()} + aria-label="Download voice message" + > + + + ); + }, + + Icon: () => ( + + + + ), +}); diff --git a/src/plugins/voiceDownload/style.css b/src/plugins/voiceDownload/style.css new file mode 100644 index 000000000..2b776023f --- /dev/null +++ b/src/plugins/voiceDownload/style.css @@ -0,0 +1,12 @@ +.vc-voice-download { + width: 24px; + height: 24px; + color: var(--interactive-normal); + margin-left: 12px; + cursor: pointer; + position: relative; +} + +.vc-voice-download:hover { + color: var(--interactive-active); +} diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ab6c0bb70..a0c4752dc 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -430,6 +430,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "newwares", id: 421405303951851520n }, + puv: { + name: "puv", + id: 469441552251355137n + }, Kodarru: { name: "Kodarru", id: 785227396218748949n