BetterSettings: This is a sin

This commit is contained in:
thororen1234 2026-05-22 17:29:33 -04:00
parent 329b331abe
commit 205d56653f
No known key found for this signature in database
3 changed files with 57 additions and 8 deletions

View file

@ -1142,3 +1142,31 @@ export function PencilSparkleIcon(props: IconProps) {
</Icon>
);
}
export function HammerIcon(props: IconProps) {
return (
<Icon
{...props}
viewBox="0 0 24 24"
>
<path
fill={props.fill || "currentColor"}
d="M1.23 21.13a1 1 0 0 1 0-1.41l7.48-7.47c.2-.2.51-.2.7 0l2.13 2.12c.2.2.2.5 0 .7l-7.48 7.48a1 1 0 0 1-1.41 0l-1.42-1.42ZM7.76 7.76l8.48 8.49a2 2 0 0 0 2.83 0l3.54-3.54a2 2 0 0 0 0-2.83l-2.94-2.94.65-.66a1 1 0 0 0 0-1.4l-1.41-1.42a1 1 0 0 0-1.41 0l-.66.65-2.72-2.71a2 2 0 0 0-2.83 0L7.76 4.93a2 2 0 0 0 0 2.83Z"
/>
</Icon>
);
}
export function AchievementsIcon(props: IconProps) {
return (
<Icon
{...props}
viewBox="0 0 24 24"
>
<path
fill={props.fill || "currentColor"}
d="M13.76 4.97a1 1 0 0 1-.73-1.21l.5-2a1 1 0 1 1 1.94.48l-.5 2a1 1 0 0 1-1.21.73ZM19.2 3.8a1 1 0 0 1 0 1.4l-1.5 1.5a1 1 0 1 1-1.4-1.4l1.5-1.5a1 1 0 0 1 1.4 0ZM7.46 11.05 9.6 8.2a3 3 0 0 1 4.8 0l2.14 2.85-.83.83a1 1 0 0 1-1.42 0l-.17-.17a3 3 0 0 0-4.24 0l-.17.17a1 1 0 0 1-1.42 0l-.83-.83ZM6.25 12.67 2.4 17.8A2 2 0 0 0 4 21h16a2 2 0 0 0 1.6-3.2l-3.85-5.13-.63.62a3 3 0 0 1-4.24 0l-.17-.17a1 1 0 0 0-1.42 0l-.17.17a3 3 0 0 1-4.24 0l-.63-.62ZM4.8 5.2a1 1 0 0 1 1.4-1.4l1.5 1.5a1 1 0 0 1-1.4 1.4L4.8 5.2ZM21.97 8.26a1 1 0 0 1-.73 1.21l-2 .5a1 1 0 1 1-.48-1.94l2-.5a1 1 0 0 1 1.21.73ZM2.76 9.47a1 1 0 1 1 .48-1.94l2 .5a1 1 0 1 1-.48 1.94l-2-.5ZM10.97 3.76a1 1 0 0 1-1.94.48l-.5-2a1 1 0 1 1 1.94-.48l.5 2Z"
/>
</Icon>
);
}

View file

@ -6,7 +6,7 @@
import { definePluginSettings } from "@api/Settings";
import { disableStyle, enableStyle } from "@api/Styles";
import { AppsIcon, CreditCardIcon, DeveloperIcon, EquicordIcon, GameControllerIcon, MainSettingsIcon, PencilSparkleIcon, UserIcon } from "@components/Icons";
import { AchievementsIcon, AppsIcon, CreditCardIcon, DeveloperIcon, EquicordIcon, GameControllerIcon, HammerIcon, MainSettingsIcon, PencilSparkleIcon, UserIcon } from "@components/Icons";
import { buildPluginMenuEntries, buildThemeMenuEntries } from "@equicordplugins/equicordToolbox/menu";
import { Devs } from "@utils/constants";
import { classNameFactory } from "@utils/css";
@ -32,6 +32,8 @@ const SECTION_ICONS: Record<string, Icon> = {
activity_section: GameControllerIcon,
developer_section: DeveloperIcon,
utility_section: MainSettingsIcon,
playgrounds_section: AchievementsIcon,
build_overrides_section: HammerIcon,
};
const settings = definePluginSettings({
@ -169,11 +171,23 @@ export default definePlugin({
predicate: () => settings.store.organizeMenu,
replacement: [
{
match: /children:\[(\i),(?<=\1=(?:function|.{0,30}\.openUserSettings).+?)/, // TODO .{0,30}\.openUserSettings is stable compat
replace: "children:[$self.transformSettingsEntries($1),",
match: /"clear-build-override"\)\]\}/,
replace: '$&,"build_overrides_section"'
},
{
match: /children:\[(\i),null!=(\i).{0,30}\}\),(\i)\](?<=\1=(?:function|.{0,30}\.openUserSettings).+?)/, // TODO .{0,30}\.openUserSettings is stable compat
replace: "children:$self.transformSettingsEntries([$1,$2,$3])",
}
]
},
{
find: '},"design-systems")',
predicate: () => settings.store.organizeMenu,
replacement: {
match: /\},"playgrounds"\)/,
replace: '},"playgrounds_section")'
}
},
],
// This is the very outer layer of the entire ui, so we can't wrap this in an ErrorBoundary
@ -194,12 +208,14 @@ export default definePlugin({
transformSettingsEntries(list) {
const items: ReactNode[] = [];
const SECTION_NAMES: Record<string, string> = {
profile_section: getIntlMessage("EDIT_PROFILES"),
user_section: getIntlMessage("ACCOUNT_SETTINGS"),
utility_section: getIntlMessage("USER_SETTINGS_KEYBINDS_MISCELLANEOUS_SECTION_TITLE")
};
for (const item of list) {
const flat = list.flat(Infinity);
let logout: ReactNode = null;
for (const item of flat) {
const { key, props } = item;
if (!props) continue;
@ -213,8 +229,12 @@ export default definePlugin({
{children}
</Menu.MenuItem>
);
} else if (key.endsWith("_section") && (props.label ?? SECTION_NAMES[key])) {
} else if (key?.endsWith("_section") && (props.label ?? SECTION_NAMES[key])) {
const iconLeft = SECTION_ICONS[key];
const children: any = [].concat(props.children ?? []).flat(Infinity);
const logoutItem = children.find(c => c?.key === "logout_sidebar_item");
if (logoutItem) logout = <Menu.MenuItem key={logoutItem.key} {...logoutItem.props} />;
items.push(
<Menu.MenuItem
key={key}
@ -222,7 +242,7 @@ export default definePlugin({
id={props.label ?? SECTION_NAMES[key]}
{...(iconLeft && { iconLeft })}
>
{this.transformSettingsEntries(props.children)}
{this.transformSettingsEntries(children.filter(c => c?.key !== "logout_sidebar_item"))}
</Menu.MenuItem>
);
} else {
@ -230,6 +250,7 @@ export default definePlugin({
}
}
if (logout) items.push(logout);
return items;
}
});

View file

@ -143,7 +143,7 @@ export default definePlugin({
replace: "$1[$2,$self.renderConnectionTimer({ channelId: this?.props?.channel?.id })]"
},
{
match: /("RTCConnectionMenu".{0,100}?lineClamp:1,children:)(\i)(?=,|}\))/,
match: /("RTCConnectionMenu".{0,200}?lineClamp:1,children:)(\i)(?=,|}\))/,
replace: "$1[$2,$self.renderConnectionTimer({ channelId: this?.props?.channel?.id })]"
}
]