mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Merge branch 'dev' of https://github.com/Vendicated/Vencord into discord-types
This commit is contained in:
commit
351fbf82b9
15 changed files with 274 additions and 48 deletions
|
@ -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": {
|
||||
|
|
|
@ -48,9 +48,9 @@ const Icon = ({ height = 24, width = 24, className, children, viewBox, ...svgPro
|
|||
*/
|
||||
export const LinkIcon = ({ height = 24, width = 24, className }: IconProps) => (
|
||||
<Icon
|
||||
height={height}
|
||||
width={width}
|
||||
className={classes(className, "vc-link-icon")}
|
||||
width={width}
|
||||
height={height}
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
|
@ -59,8 +59,7 @@ export const 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 const CopyIcon = (props: IconProps) => (
|
||||
<Icon
|
||||
|
@ -69,7 +68,7 @@ export const CopyIcon = (props: IconProps) => (
|
|||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z" />
|
||||
<path d="M3 16a1 1 0 0 1-1-1v-5a8 8 0 0 1 8-8h5a1 1 0 0 1 1 1v.5a.5.5 0 0 1-.5.5H10a6 6 0 0 0-6 6v5.5a.5.5 0 0 1-.5.5H3Zm3 2a4 4 0 0 0 4 4h8a4 4 0 0 0 4-4v-4h-3a5 5 0 0 1-5-5V6h-4a4 4 0 0 0-4 4v8Zm15.73-6a3 3 0 0 0-.6-.88l-4.25-4.24a3 3 0 0 0-.88-.61V9a3 3 0 0 0 3 3h2.73Z" />
|
||||
</Icon>
|
||||
);
|
||||
|
||||
|
|
|
@ -406,6 +406,7 @@ function PatchHelper() {
|
|||
<Forms.FormTitle className={Margins.top20}>Code</Forms.FormTitle>
|
||||
<CodeBlock lang="js" content={code} />
|
||||
<Button onClick={() => { ClipboardUtils.copy(code); }}>Copy to Clipboard</Button>
|
||||
<Button className={Margins.top8} onClick={() => { ClipboardUtils.copy("```ts\n" + code + "\n```"); }}>Copy as Codeblock</Button>
|
||||
</>
|
||||
)}
|
||||
</SettingsTab>
|
||||
|
|
5
src/plugins/CopyFileContents/README.md
Normal file
5
src/plugins/CopyFileContents/README.md
Normal file
|
@ -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)
|
70
src/plugins/CopyFileContents/index.tsx
Normal file
70
src/plugins/CopyFileContents/index.tsx
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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 = () => (
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="currentColor"
|
||||
>
|
||||
<path d="M21.7 5.3a1 1 0 0 1 0 1.4l-12 12a1 1 0 0 1-1.4 0l-6-6a1 1 0 1 1 1.4-1.4L9 16.58l11.3-11.3a1 1 0 0 1 1.4 0Z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
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 (
|
||||
<Tooltip text={recentlyCopied ? "Copied!" : bytesLeft > 0 ? "File too large to copy" : "Copy File Contents"}>
|
||||
{tooltipProps => (
|
||||
<div
|
||||
{...tooltipProps}
|
||||
className="vc-cfc-button"
|
||||
role="button"
|
||||
onClick={() => {
|
||||
if (!recentlyCopied && bytesLeft <= 0) {
|
||||
copyWithToast(fileContents);
|
||||
setRecentlyCopied(true);
|
||||
setTimeout(() => { setRecentlyCopied(false); }, 2000);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{recentlyCopied
|
||||
? <CheckMarkIcon />
|
||||
: bytesLeft > 0
|
||||
? <NoEntrySignIcon color="var(--channel-icon)" />
|
||||
: <CopyIcon />
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
</Tooltip>
|
||||
);
|
||||
}, { noop: true }),
|
||||
});
|
8
src/plugins/CopyFileContents/style.css
Normal file
8
src/plugins/CopyFileContents/style.css
Normal file
|
@ -0,0 +1,8 @@
|
|||
.vc-cfc-button {
|
||||
color: var(--interactive-normal);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.vc-cfc-button:hover {
|
||||
color: var(--interactive-hover);
|
||||
}
|
|
@ -34,7 +34,7 @@ interface URLReplacementRule {
|
|||
// Do not forget to add protocols to the ALLOWED_PROTOCOLS constant
|
||||
const UrlReplacementRules: Record<string, URLReplacementRule> = {
|
||||
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\/.+$/,
|
||||
|
|
3
src/plugins/stickerPaste/README.md
Normal file
3
src/plugins/stickerPaste/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# StickerPaste
|
||||
|
||||
Makes picking a sticker in the sticker picker insert it into the chatbox instead of instantly sending.
|
24
src/plugins/stickerPaste/index.ts
Normal file
24
src/plugins/stickerPaste/index.ts
Normal file
|
@ -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;$&",
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
5
src/plugins/timeBarAllActivities/README.md
Normal file
5
src/plugins/timeBarAllActivities/README.md
Normal file
|
@ -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)
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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"
|
||||
}
|
||||
}
|
||||
],
|
||||
});
|
76
src/plugins/timeBarAllActivities/index.tsx
Normal file
76
src/plugins/timeBarAllActivities/index.tsx
Normal file
|
@ -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<ActivityTimestamps>(".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 <ActivityTimeBar start={activity.timestamps!.start} end={activity.timestamps!.end} />;
|
||||
}
|
||||
}
|
||||
});
|
9
src/plugins/volumeBooster/README.md
Normal file
9
src/plugins/volumeBooster/README.md
Normal file
|
@ -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)
|
|
@ -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<Omit<Patch, "plugin">>(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;
|
||||
}
|
||||
});
|
|
@ -534,6 +534,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "Joona",
|
||||
id: 297410829589020673n
|
||||
},
|
||||
sadan: {
|
||||
name: "sadan",
|
||||
id: 521819891141967883n,
|
||||
},
|
||||
Kylie: {
|
||||
name: "Cookie",
|
||||
id: 721853658941227088n
|
||||
|
@ -550,10 +554,18 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "Lumap",
|
||||
id: 585278686291427338n,
|
||||
},
|
||||
Obsidian: {
|
||||
name: "Obsidian",
|
||||
id: 683171006717755446n,
|
||||
},
|
||||
SerStars: {
|
||||
name: "SerStars",
|
||||
id: 861631850681729045n,
|
||||
},
|
||||
niko: {
|
||||
name: "niko",
|
||||
id: 341377368075796483n,
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
Loading…
Reference in a new issue