ShowMeYourName Extra Settings & Fix WhosWatching

This commit is contained in:
thororen1234 2025-05-01 14:09:40 -04:00
parent 0d09c083c6
commit efd1821fad
No known key found for this signature in database
3 changed files with 53 additions and 24 deletions

View file

@ -11,8 +11,8 @@ import { makeRange } from "@components/PluginSettings/components";
import { debounce } from "@shared/debounce"; import { debounce } from "@shared/debounce";
import { EquicordDevs } from "@utils/constants"; import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy, findByCode, findByProps } from "@webpack"; import { findByCode, findByProps, findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
import { ChannelStore, ContextMenuApi, GuildStore, IconUtils, Menu, ChannelRouter, PermissionStore, React, SelectedChannelStore, PermissionsBits, Toasts, UserStore } from "@webpack/common"; import { ChannelRouter, ChannelStore, ContextMenuApi, GuildStore, Menu, PermissionsBits, PermissionStore, React, SelectedChannelStore, Toasts, UserStore } from "@webpack/common";
import style from "./styles.css?managed"; import style from "./styles.css?managed";
@ -86,10 +86,10 @@ const settings = definePluginSettings({
description: "Automatically turns on camera", description: "Automatically turns on camera",
default: false, default: false,
}, },
autoStream: { autoStream: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
description: "Automatically turns on stream", description: "Automatically turns on stream",
default: false, default: false,
}, },
selfMute: { selfMute: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
@ -101,10 +101,10 @@ const settings = definePluginSettings({
description: "Automatically deafems your mic when joining voice-channel.", description: "Automatically deafems your mic when joining voice-channel.",
default: false, default: false,
}, },
leaveEmpty: { leaveEmpty: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
description: "Finds a random-call, when the voice chat is empty.", description: "Finds a random-call, when the voice chat is empty.",
default: false, default: false,
}, },
avoidStages: { avoidStages: {
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
@ -177,21 +177,21 @@ export default definePlugin({
} }
], ],
flux: { flux: {
VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[] }) { VOICE_STATE_UPDATES({ voiceStates }: { voiceStates: VoiceState[]; }) {
const currentUserId = UserStore.getCurrentUser().id; const currentUserId = UserStore.getCurrentUser().id;
const myChannelId = VoiceStateStore.getVoiceStateForUser(currentUserId)?.channelId; const myChannelId = VoiceStateStore.getVoiceStateForUser(currentUserId)?.channelId;
if (!myChannelId || !settings.store.leaveEmpty) return; if (!myChannelId || !settings.store.leaveEmpty) return;
const voiceStatesMap = VoiceStateStore.getVoiceStates() as Record<string, VoiceState>; const voiceStatesMap = VoiceStateStore.getVoiceStates() as Record<string, VoiceState>;
const othersInChannel = Object.values(voiceStatesMap).filter(vs => const othersInChannel = Object.values(voiceStatesMap).filter(vs =>
vs.channelId === myChannelId && vs.userId !== currentUserId vs.channelId === myChannelId && vs.userId !== currentUserId
); );
if (othersInChannel.length === 0) { if (othersInChannel.length === 0) {
randomVoice() randomVoice();
} }
}, },
}, },
start() { start() {
enableStyle(style); enableStyle(style);
}, },
@ -261,7 +261,7 @@ function ContextMenu() {
aria-label="Voice state modifier" aria-label="Voice state modifier"
> >
<Menu.MenuItem <Menu.MenuItem
id="servers" id="servers"
label="Select Servers" label="Select Servers"

View file

@ -82,10 +82,9 @@ export default definePlugin({
} }
}, },
{ {
predicate: () => settings.store.showPanel,
find: "this.renderEmbeddedActivity()", find: "this.renderEmbeddedActivity()",
replacement: { replacement: {
match: /(?<=children.{0,50})"div"(?=.{0,500}this\.renderEmbeddedActivity\(\))/, match: /(?<=render\(\).{0,500}children.{0,50})"div"(?=.{0,500}this\.renderEmbeddedActivity\(\))/,
replace: "$self.WrapperComponent" replace: "$self.WrapperComponent"
} }
} }
@ -118,7 +117,7 @@ export default definePlugin({
return ( return (
<> <>
<div {...props}>{props.children}</div> <div {...props}>{props.children}</div>
<div className={classes(cl("spectators_panel"), Margins.top8)} style={{ marginLeft: 8 }}> <div className={classes(cl("spectators_panel"), Margins.top8)}>
<Forms.FormTitle tag="h3" style={{ marginTop: 8, marginBottom: 0, textTransform: "uppercase" }}> <Forms.FormTitle tag="h3" style={{ marginTop: 8, marginBottom: 0, textTransform: "uppercase" }}>
{getIntlMessage("SPECTATORS", { numViewers: userIds.length })} {getIntlMessage("SPECTATORS", { numViewers: userIds.length })}
</Forms.FormTitle> </Forms.FormTitle>

View file

@ -45,9 +45,26 @@ const settings = definePluginSettings({
type: OptionType.BOOLEAN, type: OptionType.BOOLEAN,
default: false, default: false,
description: "Use friend names in place of usernames (overrides Display Names option if applicable)" description: "Use friend names in place of usernames (overrides Display Names option if applicable)"
} },
memberList: {
type: OptionType.BOOLEAN,
default: true,
description: "Show usernames in member list",
},
voiceChannelList: {
type: OptionType.BOOLEAN,
default: true,
description: "Show usernames in voice channel list",
},
}); });
function getUsername(user: any): string {
const friendName = RelationshipStore.getNickname(user.id);
if (settings.store.preferFriend && friendName) return friendName;
if (settings.store.displayNames) return user.globalName || user.username;
return user.username;
}
export default definePlugin({ export default definePlugin({
name: "ShowMeYourName", name: "ShowMeYourName",
description: "Display usernames next to nicks, or no nicks at all", description: "Display usernames next to nicks, or no nicks at all",
@ -61,18 +78,31 @@ export default definePlugin({
replace: "$self.renderUsername(arguments[0])" replace: "$self.renderUsername(arguments[0])"
} }
}, },
{
find: "._areActivitiesExperimentallyHidden=(",
replacement: {
match: /(?<=user:(\i),currentUser:\i,nick:)\i/,
replace: "$self.getUsername($1)"
},
predicate: () => settings.store.memberList
},
{
find: ".usernameSpeaking]",
predicate: () => settings.store.voiceChannelList,
replacement: [
{
match: /(?<=children:\[null!=\i\?)\i(?=:\i\.\i\.getName\((\i)\))/,
replace: "$self.getUsername($1)"
},
]
},
], ],
settings, settings,
getUsername,
renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => { renderUsername: ErrorBoundary.wrap(({ author, message, isRepliedMessage, withMentionPrefix, userOverride }: UsernameProps) => {
try { try {
const user = userOverride ?? message.author; const user = userOverride ?? message.author;
const friendName = RelationshipStore.getNickname(user.id); const username = getUsername(user);
let { username } = user;
if (settings.store.displayNames)
username = (user as any).globalName || username;
if (settings.store.preferFriend)
username = friendName ?? username;
const { nick } = author; const { nick } = author;
const prefix = withMentionPrefix ? "@" : ""; const prefix = withMentionPrefix ? "@" : "";