Plugin
VencordToolbox
Adds a button to the titlebar that houses Vencord quick actions
1
import "./styles.css";2
3
import { definePluginSettings } from "@api/Settings";4
import ErrorBoundary from "@components/ErrorBoundary";5
import { Devs } from "@utils/constants";6
import definePlugin, { OptionType } from "@utils/types";7
import { findComponentByCodeLazy } from "@webpack";8
import { Popout, useRef, useState } from "@webpack/common";9
import type { PropsWithChildren } from "react";10
11
import { renderPopout } from "./menu";12
13
const HeaderBarIcon = findComponentByCodeLazy(".HEADER_BAR_BADGE_BOTTOM,", 039;position:"bottom"039;);14
15
export const settings = definePluginSettings({16
showPluginMenu: {17
type: OptionType.BOOLEAN,18
default: true,19
description: "Show the plugins menu in the toolbox",20
}21
});22
23
function Icon({ isShown }: { isShown: boolean; }) {24
return (25
<svg viewBox="0 0 27 27" width={18} height={18} className="vc-toolbox-icon">26
{isShown27
? <path fill="currentColor" d="M9 0h1v1h1v2h1v2h3V3h1V1h1V0h1v2h1v2h1v7h-1v-1h-3V9h1V6h-1v4h-3v1h1v-1h2v1h3v1h-1v1h-3v2h1v1h1v1h1v3h-1v4h-2v-1h-1v-4h-1v4h-1v1h-2v-4H9v-3h1v-1h1v-1h1v-2H9v-1H8v-1h3V6h-1v3h1v1H8v1H7V4h1V2h1M5 19h2v1h1v1h1v3H4v-1h2v-1H4v-2h1m15-1h2v1h1v2h-2v1h2v1h-5v-3h1v-1h1m4 3h4v1h-4" />28
: <path fill="currentColor" d="M0 0h7v1H6v1H5v1H4v1H3v1H2v1h5v1H0V6h1V5h1V4h1V3h1V2h1V1H0m13 2h5v1h-1v1h-1v1h-1v1h3v1h-5V7h1V6h1V5h1V4h-3m8 5h1v5h1v-1h1v1h-1v1h1v-1h1v1h-1v3h-1v1h-2v1h-1v1h1v-1h2v-1h1v2h-1v1h-2v1h-1v-1h-1v1h-6v-1h-1v-1h-1v-2h1v1h2v1h3v1h1v-1h-1v-1h-3v-1h-4v-4h1v-2h1v-1h1v-1h1v2h1v1h1v-1h1v1h-1v1h2v-2h1v-2h1v-1h1M8 14h2v1H9v4h1v2h1v1h1v1h1v1h4v1h-6v-1H5v-1H4v-5h1v-1h1v-2h2m17 3h1v3h-1v1h-1v1h-1v2h-2v-2h2v-1h1v-1h1m1 0h1v3h-1v1h-2v-1h1v-1h1" />29
}30
</svg>31
);32
}33
34
function VencordPopoutButton() {35
const buttonRef = useRef(null);36
const [show, setShow] = useState(false);37
38
return (39
<Popout40
position="bottom"41
align="right"42
animation={Popout.Animation.NONE}43
shouldShow={show}44
onRequestClose={() => setShow(false)}45
targetElementRef={buttonRef}46
renderPopout={() => renderPopout(() => setShow(false))}47
>48
{(_, { isShown }) => (49
<HeaderBarIcon50
ref={buttonRef}51
className="vc-toolbox-btn"52
onClick={() => setShow(v => !v)}53
tooltip={isShown ? null : "Vencord Toolbox"}54
icon={() => <Icon isShown={isShown} />}55
selected={isShown}56
/>57
)}58
</Popout>59
);60
}61
62
export default definePlugin({63
name: "FiveCordToolbox",64
description: "Adds a button to the titlebar that houses FiveCord quick actions",65
tags: ["Utility", "Developers"], 66
authors: [Devs.FiveCord],67
68
settings,69
70
patches: [71
{72
find: 039;?"BACK_FORWARD_NAVIGATION":039;,73
replacement: {74
match: /(trailing:.{0,50}?)\i\.Fragment,(?=\{children:\[)/,75
replace: "$1$self.TrailingWrapper,"76
}77
}78
],79
80
TrailingWrapper({ children }: PropsWithChildren) {81
return (82
<>83
{children}84
<ErrorBoundary key="vc-toolbox" noop>85
<VencordPopoutButton />86
</ErrorBoundary>87
</>88
);89
},90
});91