From 00276cad7ceba8bb35c6cb551c866e8e2fe34f54 Mon Sep 17 00:00:00 2001 From: niko <57009359+hauntii@users.noreply.github.com> Date: Sat, 31 Aug 2024 21:45:57 -0400 Subject: [PATCH 1/7] TimeBarAllActivities: Support new activity cards (#2813) --- src/plugins/timeBarAllActivities/README.md | 5 ++ src/plugins/timeBarAllActivities/index.ts | 35 ---------- src/plugins/timeBarAllActivities/index.tsx | 76 ++++++++++++++++++++++ src/utils/constants.ts | 4 ++ 4 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 src/plugins/timeBarAllActivities/README.md delete mode 100644 src/plugins/timeBarAllActivities/index.ts create mode 100644 src/plugins/timeBarAllActivities/index.tsx diff --git a/src/plugins/timeBarAllActivities/README.md b/src/plugins/timeBarAllActivities/README.md new file mode 100644 index 000000000..59f0451c2 --- /dev/null +++ b/src/plugins/timeBarAllActivities/README.md @@ -0,0 +1,5 @@ +# TimeBarAllActivities + +Adds the Spotify time bar to all activities if they have start and end timestamps. + +![](https://github.com/user-attachments/assets/9fbbe33c-8218-43c9-8b8d-f907a4e809fe) diff --git a/src/plugins/timeBarAllActivities/index.ts b/src/plugins/timeBarAllActivities/index.ts deleted file mode 100644 index dcb809fd4..000000000 --- a/src/plugins/timeBarAllActivities/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 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: "TimeBarAllActivities", - description: "Adds the Spotify time bar to all activities if they have start and end timestamps", - authors: [Devs.fawn], - patches: [ - { - find: "}renderTimeBar(", - replacement: { - match: /renderTimeBar\((.{1,3})\){.{0,50}?let/, - replace: "renderTimeBar($1){let" - } - } - ], -}); diff --git a/src/plugins/timeBarAllActivities/index.tsx b/src/plugins/timeBarAllActivities/index.tsx new file mode 100644 index 000000000..04f7ff9e7 --- /dev/null +++ b/src/plugins/timeBarAllActivities/index.tsx @@ -0,0 +1,76 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; +import { findComponentByCodeLazy } from "@webpack"; + +interface Activity { + timestamps?: ActivityTimestamps; +} + +interface ActivityTimestamps { + start?: string; + end?: string; +} + +const ActivityTimeBar = findComponentByCodeLazy(".Millis.HALF_SECOND", ".bar", ".progress"); + +export const settings = definePluginSettings({ + hideActivityDetailText: { + type: OptionType.BOOLEAN, + description: "Hide the large title text next to the activity", + default: true, + }, + hideActivityTimerBadges: { + type: OptionType.BOOLEAN, + description: "Hide the timer badges next to the activity", + default: true, + } +}); + +export default definePlugin({ + name: "TimeBarAllActivities", + description: "Adds the Spotify time bar to all activities if they have start and end timestamps", + authors: [Devs.fawn, Devs.niko], + settings, + patches: [ + { + find: ".Messages.USER_ACTIVITY_PLAYING", + replacement: [ + // Insert Spotify time bar component + { + match: /\(0,.{0,30}activity:(\i),className:\i\.badges\}\)/g, + replace: "$&,$self.getTimeBar($1)" + }, + // Hide the large title on listening activities, to make them look more like Spotify (also visible from hovering over the large icon) + { + match: /(\i).type===(\i\.\i)\.WATCHING/, + replace: "($self.settings.store.hideActivityDetailText&&$self.isActivityTimestamped($1)&&$1.type===$2.LISTENING)||$&" + } + ] + }, + // Hide the "badge" timers that count the time since the activity starts + { + find: ".TvIcon).otherwise", + replacement: { + match: /null!==\(\i=null===\(\i=(\i)\.timestamps\).{0,50}created_at/, + replace: "($self.settings.store.hideActivityTimerBadges&&$self.isActivityTimestamped($1))?null:$&" + } + } + ], + + isActivityTimestamped(activity: Activity) { + return activity.timestamps != null && activity.timestamps.start != null && activity.timestamps.end != null; + }, + + getTimeBar(activity: Activity) { + if (this.isActivityTimestamped(activity)) { + return ; + } + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 77d3951b9..ae1943b05 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -554,6 +554,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "SerStars", id: 861631850681729045n, }, + niko: { + name: "niko", + id: 341377368075796483n, + }, } satisfies Record); // iife so #__PURE__ works correctly From d5eaae9d5137d4eb2c77517080e1ee554ab2f5ba Mon Sep 17 00:00:00 2001 From: Obsidian <108832807+Obsidianninja11@users.noreply.github.com> Date: Sat, 31 Aug 2024 18:02:27 -0800 Subject: [PATCH 2/7] new plugin CopyFileContents ~Easily copy text file attachments contents (#2790) --- src/components/Icons.tsx | 8 ++-- src/plugins/CopyFileContents/README.md | 5 +++ src/plugins/CopyFileContents/index.tsx | 60 ++++++++++++++++++++++++++ src/plugins/CopyFileContents/style.css | 8 ++++ src/utils/constants.ts | 4 ++ 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 src/plugins/CopyFileContents/README.md create mode 100644 src/plugins/CopyFileContents/index.tsx create mode 100644 src/plugins/CopyFileContents/style.css diff --git a/src/components/Icons.tsx b/src/components/Icons.tsx index 7ba078d33..fa142a18c 100644 --- a/src/components/Icons.tsx +++ b/src/components/Icons.tsx @@ -65,8 +65,7 @@ export function LinkIcon({ height = 24, width = 24, className }: IconProps) { } /** - * Discord's copy icon, as seen in the user popout right of the username when clicking - * your own username in the bottom left user panel + * Discord's copy icon, as seen in the user panel popout on the right of the username and in large code blocks */ export function CopyIcon(props: IconProps) { return ( @@ -76,8 +75,9 @@ export function CopyIcon(props: IconProps) { viewBox="0 0 24 24" > - - + + + ); diff --git a/src/plugins/CopyFileContents/README.md b/src/plugins/CopyFileContents/README.md new file mode 100644 index 000000000..18dc2d3df --- /dev/null +++ b/src/plugins/CopyFileContents/README.md @@ -0,0 +1,5 @@ +# CopyFileContents + +Adds a button to text file attachments to copy their contents. + +![](https://github.com/user-attachments/assets/b1a0f6f4-106f-4953-94d9-4c5ef5810bca) diff --git a/src/plugins/CopyFileContents/index.tsx b/src/plugins/CopyFileContents/index.tsx new file mode 100644 index 000000000..13b649174 --- /dev/null +++ b/src/plugins/CopyFileContents/index.tsx @@ -0,0 +1,60 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./style.css"; + +import ErrorBoundary from "@components/ErrorBoundary"; +import { CopyIcon, NoEntrySignIcon } from "@components/Icons"; +import { Devs } from "@utils/constants"; +import { copyWithToast } from "@utils/misc"; +import definePlugin from "@utils/types"; +import { Tooltip, useState } from "@webpack/common"; + +const CheckMarkIcon = () => { + return + + ; +}; + +export default definePlugin({ + name: "CopyFileContents", + description: "Adds a button to text file attachments to copy their contents", + authors: [Devs.Obsidian, Devs.Nuckyz], + patches: [ + { + find: ".Messages.PREVIEW_BYTES_LEFT.format(", + replacement: { + match: /\.footerGap.+?url:\i,fileName:\i,fileSize:\i}\),(?<=fileContents:(\i),bytesLeft:(\i).+?)/g, + replace: "$&$self.addCopyButton({fileContents:$1,bytesLeft:$2})," + } + } + ], + + addCopyButton: ErrorBoundary.wrap(({ fileContents, bytesLeft }: { fileContents: string, bytesLeft: number; }) => { + const [recentlyCopied, setRecentlyCopied] = useState(false); + + return ( + 0 ? "File too large to copy" : "Copy File Contents"}> + {tooltipProps => ( +
{ + if (!recentlyCopied && bytesLeft <= 0) { + copyWithToast(fileContents); + setRecentlyCopied(true); + setTimeout(() => setRecentlyCopied(false), 2000); + } + }} + > + {recentlyCopied ? : bytesLeft > 0 ? : } +
+ )} +
+ ); + }, { noop: true }), +}); diff --git a/src/plugins/CopyFileContents/style.css b/src/plugins/CopyFileContents/style.css new file mode 100644 index 000000000..c643cf0f0 --- /dev/null +++ b/src/plugins/CopyFileContents/style.css @@ -0,0 +1,8 @@ +.vc-cfc-button { + color: var(--interactive-normal); + cursor: pointer; +} + +.vc-cfc-button:hover { + color: var(--interactive-hover); +} diff --git a/src/utils/constants.ts b/src/utils/constants.ts index ae1943b05..60c203252 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -550,6 +550,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Lumap", id: 585278686291427338n, }, + Obsidian: { + name: "Obsidian", + id: 683171006717755446n, + }, SerStars: { name: "SerStars", id: 861631850681729045n, From 81eabc7ee2504d501fe962d914961038831af496 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 31 Aug 2024 22:13:22 -0400 Subject: [PATCH 3/7] PatchHelper: Add Copy as Codeblock button (#2820) --- src/components/VencordSettings/PatchHelperTab.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/VencordSettings/PatchHelperTab.tsx b/src/components/VencordSettings/PatchHelperTab.tsx index e09a1dbf3..fd33c09df 100644 --- a/src/components/VencordSettings/PatchHelperTab.tsx +++ b/src/components/VencordSettings/PatchHelperTab.tsx @@ -382,6 +382,7 @@ function PatchHelper() { Code + )} From 273981deb74039c0aa8252f5c981d21f7352a412 Mon Sep 17 00:00:00 2001 From: ImBanana Date: Sun, 1 Sep 2024 05:33:07 +0300 Subject: [PATCH 4/7] new plugin StickerPaste ~ Insert stickers instead of sending (#2781) --- src/plugins/stickerPaste/README.md | 3 +++ src/plugins/stickerPaste/index.ts | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/plugins/stickerPaste/README.md create mode 100644 src/plugins/stickerPaste/index.ts diff --git a/src/plugins/stickerPaste/README.md b/src/plugins/stickerPaste/README.md new file mode 100644 index 000000000..a29170272 --- /dev/null +++ b/src/plugins/stickerPaste/README.md @@ -0,0 +1,3 @@ +# StickerPaste + +Makes picking a sticker in the sticker picker insert it into the chatbox instead of instantly sending. diff --git a/src/plugins/stickerPaste/index.ts b/src/plugins/stickerPaste/index.ts new file mode 100644 index 000000000..8a0082073 --- /dev/null +++ b/src/plugins/stickerPaste/index.ts @@ -0,0 +1,24 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 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: "StickerPaste", + description: "Makes picking a sticker in the sticker picker insert it into the chatbox instead of instantly sending", + authors: [Devs.ImBanana], + + patches: [ + { + find: ".stickers,previewSticker:", + replacement: { + match: /if\(\i\.\i\.getUploadCount/, + replace: "return true;$&", + } + } + ] +}); From e07a4e19e65b556b0e398a39499b85b88699756b Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Sat, 31 Aug 2024 23:08:33 -0400 Subject: [PATCH 5/7] VolumeBooster: Support browser and Vesktop (#2730) --- src/plugins/volumeBooster/README.md | 9 +++ .../index.ts | 61 +++++++++++++++++-- src/utils/constants.ts | 4 ++ 3 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 src/plugins/volumeBooster/README.md rename src/plugins/{volumeBooster.discordDesktop => volumeBooster}/index.ts (64%) diff --git a/src/plugins/volumeBooster/README.md b/src/plugins/volumeBooster/README.md new file mode 100644 index 000000000..62bd5ab52 --- /dev/null +++ b/src/plugins/volumeBooster/README.md @@ -0,0 +1,9 @@ +# Volume Booster + +Allows you to boost the volume over 200% on desktop and over 100% on other clients. + +Works on users, bots, and streams! + +![the volume being moved up to 270% on vesktop](https://github.com/user-attachments/assets/793e012e-c069-4fa4-a3d5-61c2f55edd3e) + +![the volume being moved up to 297% on a stream](https://github.com/user-attachments/assets/77463eb9-2537-4821-a3ab-82f60633ccbc) diff --git a/src/plugins/volumeBooster.discordDesktop/index.ts b/src/plugins/volumeBooster/index.ts similarity index 64% rename from src/plugins/volumeBooster.discordDesktop/index.ts rename to src/plugins/volumeBooster/index.ts index b455c97ec..3ab47b197 100644 --- a/src/plugins/volumeBooster.discordDesktop/index.ts +++ b/src/plugins/volumeBooster/index.ts @@ -31,10 +31,27 @@ const settings = definePluginSettings({ } }); +interface StreamData { + audioContext: AudioContext, + audioElement: HTMLAudioElement, + emitter: any, + // added by this plugin + gainNode?: GainNode, + id: string, + levelNode: AudioWorkletNode, + sinkId: string, + stream: MediaStream, + streamSourceNode?: MediaStreamAudioSourceNode, + videoStreamId: string, + _mute: boolean, + _speakingFlags: number, + _volume: number; +} + export default definePlugin({ name: "VolumeBooster", - authors: [Devs.Nuckyz], - description: "Allows you to set the user and stream volume above the default maximum.", + authors: [Devs.Nuckyz, Devs.sadan], + description: "Allows you to set the user and stream volume above the default maximum", settings, patches: [ @@ -45,12 +62,28 @@ export default definePlugin({ ].map(find => ({ find, replacement: { - match: /(?<=maxValue:\i\.\i)\?(\d+?):(\d+?)(?=,)/, - replace: (_, higherMaxVolume, minorMaxVolume) => "" - + `?${higherMaxVolume}*$self.settings.store.multiplier` - + `:${minorMaxVolume}*$self.settings.store.multiplier` + match: /(?<=maxValue:)\i\.\i\?(\d+?):(\d+?)(?=,)/, + replace: (_, higherMaxVolume, minorMaxVolume) => `${higherMaxVolume}*$self.settings.store.multiplier` } })), + // Patches needed for web/vesktop + { + find: "streamSourceNode", + predicate: () => IS_WEB, + group: true, + replacement: [ + // Remove rounding algorithm + { + match: /Math\.max.{0,30}\)\)/, + replace: "arguments[0]" + }, + // Patch the volume + { + match: /\.volume=this\._volume\/100;/, + replace: ".volume=0.00;$self.patchVolume(this);" + } + ] + }, // Prevent Audio Context Settings sync from trying to sync with values above 200, changing them to 200 before we send to Discord { find: "AudioContextSettingsMigrated", @@ -83,4 +116,20 @@ export default definePlugin({ ] } ], + + patchVolume(data: StreamData) { + if (data.stream.getAudioTracks().length === 0) return; + + data.streamSourceNode ??= data.audioContext.createMediaStreamSource(data.stream); + + if (!data.gainNode) { + const gain = data.gainNode = data.audioContext.createGain(); + data.streamSourceNode.connect(gain); + gain.connect(data.audioContext.destination); + } + + data.gainNode.gain.value = data._mute + ? 0 + : data._volume / 100; + } }); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 60c203252..7fb2b6bf0 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -534,6 +534,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Joona", id: 297410829589020673n }, + sadan: { + name: "sadan", + id: 521819891141967883n, + }, Kylie: { name: "Cookie", id: 721853658941227088n From b595a3e33c4a39e67a36dc9041ed2aa90c30aaea Mon Sep 17 00:00:00 2001 From: vxray <41696677+vxray@users.noreply.github.com> Date: Sun, 1 Sep 2024 05:20:22 +0200 Subject: [PATCH 6/7] OpenInApp: Add support for localization in Spotify URL regex (#2776) --- src/plugins/openInApp/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/openInApp/index.ts b/src/plugins/openInApp/index.ts index 1a68e8f5d..2e332465e 100644 --- a/src/plugins/openInApp/index.ts +++ b/src/plugins/openInApp/index.ts @@ -33,7 +33,7 @@ interface URLReplacementRule { // Do not forget to add protocols to the ALLOWED_PROTOCOLS constant const UrlReplacementRules: Record = { spotify: { - match: /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/, + match: /^https:\/\/open\.spotify\.com\/(?:intl-[a-z]{2}\/)?(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/, replace: (_, type, id) => `spotify://${type}/${id}`, description: "Open Spotify links in the Spotify app", shortlinkMatch: /^https:\/\/spotify\.link\/.+$/, From 968e688c106ea7b45c1bb522c73104239d3663a6 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 1 Sep 2024 00:53:46 -0300 Subject: [PATCH 7/7] Bump to 1.9.9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fdda2659..65a2f4512 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vencord", "private": "true", - "version": "1.9.8", + "version": "1.9.9", "description": "The cutest Discord client mod", "homepage": "https://github.com/Vendicated/Vencord#readme", "bugs": {