52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
/*
|
|
* Vencord, a Discord client mod
|
|
* Copyright (c) 2025 Vendicated and contributors
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
import { isPluginEnabled } from "@api/PluginManager";
|
|
import declutter from "@equicordplugins/declutter";
|
|
import { Devs } from "@utils/constants";
|
|
import definePlugin from "@utils/types";
|
|
import { findCssClassesLazy } from "@webpack";
|
|
|
|
const accountClasses = findCssClassesLazy("iconForeground", "accountPopoutButtonWrapper");
|
|
|
|
export default definePlugin({
|
|
name: "UserAreaAPI",
|
|
description: "API to add buttons to the user area panel.",
|
|
authors: [Devs.prism],
|
|
|
|
patches: [
|
|
{
|
|
find: ".DISPLAY_NAME_STYLES_COACHMARK)",
|
|
replacement: [
|
|
{
|
|
match: /children:\[(?=.{0,50}accountContainerRef:\i)/,
|
|
replace: "children:[...$self.renderButtons(arguments[0]),"
|
|
},
|
|
// fix discord weird shrink with extra buttons
|
|
{
|
|
match: /(?<=\{ref:\i,)style:(\i)/,
|
|
replace: "style:{...$1,minWidth:0}"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
|
|
renderButtons(props: { nameplate?: any; }) {
|
|
return Vencord.Api.UserArea._renderButtons({
|
|
nameplate: !this.shouldHideNameplate() ? props.nameplate : null,
|
|
iconForeground: accountClasses.iconForeground,
|
|
hideTooltips: this.shouldHideTooltips()
|
|
});
|
|
},
|
|
|
|
shouldHideTooltips() {
|
|
return isPluginEnabled(declutter.name) && declutter.settings.store.removeButtonTooltips;
|
|
},
|
|
|
|
shouldHideNameplate() {
|
|
return isPluginEnabled(declutter.name) && declutter.settings.store.removeNameplate;
|
|
}
|
|
});
|