mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Merge 5d008b0708
into b875ebf92d
This commit is contained in:
commit
3b255c6118
2 changed files with 54 additions and 0 deletions
5
src/plugins/youtubeDescription/README.md
Normal file
5
src/plugins/youtubeDescription/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# YoutubeDescription
|
||||||
|
|
||||||
|
Adds descriptions to youtube video embeds
|
||||||
|
|
||||||
|
![demo](https://github.com/Vendicated/Vencord/assets/82430093/a69a48fa-d1a5-490d-a917-5c60e3fc38a8)
|
49
src/plugins/youtubeDescription/index.tsx
Normal file
49
src/plugins/youtubeDescription/index.tsx
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 { isNonNullish } from "@utils/guards";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { useState } from "@webpack/common";
|
||||||
|
import { Embed } from "discord-types/general";
|
||||||
|
|
||||||
|
interface ToggleableDescriptionProps { embed: Embed, original: () => any; }
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "YoutubeDescription",
|
||||||
|
description: "Adds descriptions to youtube video embeds",
|
||||||
|
authors: [Devs.arHSM],
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".default.Messages.SUPPRESS_ALL_EMBEDS",
|
||||||
|
replacement: {
|
||||||
|
match: /case (\i\.MessageEmbedTypes\.VIDEO):(case \i\.MessageEmbedTypes\.\i:)*break;default:(\i)=(?:(this\.renderDescription)\(\))\}/,
|
||||||
|
replace: "$2 break; case $1: $3 = $self.ToggleableDescriptionWrapper({ embed: this.props.embed, original: $4.bind(this) }); break; default: $3 = $4() }"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ToggleableDescription({ embed, original }: ToggleableDescriptionProps) {
|
||||||
|
const [isOpen, setOpen] = useState(false);
|
||||||
|
|
||||||
|
console.warn(embed);
|
||||||
|
|
||||||
|
return !isNonNullish(embed.rawDescription)
|
||||||
|
? null
|
||||||
|
: embed.rawDescription.length > 20
|
||||||
|
? <div
|
||||||
|
style={{ cursor: "pointer", marginTop: isOpen ? "0px" : "8px" }}
|
||||||
|
onClick={() => setOpen(o => !o)}
|
||||||
|
>
|
||||||
|
{isOpen
|
||||||
|
? original()
|
||||||
|
: embed.rawDescription.substring(0, 20) + "..."}
|
||||||
|
</div>
|
||||||
|
: original();
|
||||||
|
},
|
||||||
|
ToggleableDescriptionWrapper(props: ToggleableDescriptionProps) {
|
||||||
|
return <this.ToggleableDescription {...props}></this.ToggleableDescription>;
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue