Add BetterBlockedContext to BetterBlockedUsers

This commit is contained in:
thororen1234 2025-04-03 00:53:44 -04:00
parent c24fe61710
commit eae8947a09
No known key found for this signature in database
3 changed files with 50 additions and 27 deletions

View file

@ -25,7 +25,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch
- BetterActivities by D3SOX, Arjix, AutumnVN
- BetterAudioPlayer by Creations
- BetterBanReasons by Inbestigator
- BetterBlockedUsers by TheArmagan
- BetterBlockedUsers by TheArmagan & Elvyra
- BetterInvites by iamme
- BetterPlusReacts by Joona
- BetterQuickReact by Ven & Sqaaakoi

View file

@ -6,18 +6,30 @@
import "./styles.css";
import { EquicordDevs } from "@utils/constants";
import { getIntlMessage, openUserProfile } from "@utils/discord";
import definePlugin from "@utils/types";
import { Button, React, RelationshipStore, TextInput, UserStore } from "@webpack/common";
import { definePluginSettings } from "@api/Settings";
import { Devs, EquicordDevs } from "@utils/constants";
import { openUserProfile } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { FluxDispatcher, React, RelationshipStore, TextInput, UserStore } from "@webpack/common";
import { User } from "discord-types/general";
let lastSearch = "";
let updateFunc = (v: any) => { };
const settings = definePluginSettings({
hideBlockedWarning: {
default: true,
type: OptionType.BOOLEAN,
description: "Skip the warning about blocked/ignored users when opening the profile through the blocklist.",
restartNeeded: true,
},
});
export default definePlugin({
name: "BetterBlockedUsers",
description: "Allows you to search in blocked users list and makes names selectable in settings.",
authors: [EquicordDevs.TheArmagan],
description: "Allows you to search in blocked users list and makes names clickable in settings.",
authors: [EquicordDevs.TheArmagan, Devs.Elvyra],
settings,
patches: [
{
find: '"],{numberOfBlockedUsers:',
@ -27,8 +39,8 @@ export default definePlugin({
replace: ",$1.listType==='blocked'?$self.renderSearchInput():null"
},
{
match: /(?<=userId:(\i).*?\}\)\]\}\),)(\(.*?\)\}\))/,
replace: "$self.renderUser($1,$2),",
match: /(?<=className:\i.userInfo,)(?=children:.{0,20}user:(\i))/,
replace: "style:{cursor:'pointer'},onClick:()=>$self.openUserProfile($1),"
},
{
match: /(?<=\}=(\i).{0,10}(\i).useState\(.{0,1}\);)/,
@ -39,7 +51,28 @@ export default definePlugin({
replace: "$1(searchResults.length?searchResults:$2)"
},
]
}
},
{
find: "UserProfileModalHeaderActionButtons",
replacement: [
{
match: /(?<=return \i)\|\|(\i)===.*?.FRIEND/,
replace: (_, type) => `?null:${type} === 1|| ${type} === 2`,
},
{
match: /(?<=\i.bot.{0,50}children:.*?onClose:)(\i)/,
replace: "() => {$1();$self.closeSettingsWindow()}",
}
],
},
{
find: ',["user"])',
replacement: {
match: /(?<=isIgnored:.*?,\[\i,\i]=\i.useState\()\i\|\|\i\|\|\i.*?]\);/,
replace: "false);"
},
predicate: () => settings.store.hideBlockedWarning,
},
],
renderSearchInput() {
const [value, setValue] = React.useState(lastSearch);
@ -61,19 +94,6 @@ export default definePlugin({
}} value={value}
></TextInput>;
},
renderUser(userId: string, rest: any) {
return (
<div style={{ display: "flex", gap: "8px" }}>
<Button color={Button.Colors.PRIMARY} onClick={() => openUserProfile(userId)}>
{getIntlMessage("SHOW_USER_PROFILE")}
</Button>
{rest}
</div>
);
},
getSearchResults() {
return !!lastSearch;
},
setUpdateFunc(e, setResults) {
if (e.listType !== "blocked") return;
updateFunc = setResults;
@ -86,5 +106,11 @@ export default definePlugin({
if (!user) return id === search;
return id === search || user?.username?.toLowerCase()?.includes(search) || user?.globalName?.toLowerCase()?.includes(search);
}) as string[];
}
},
closeSettingsWindow: () => {
FluxDispatcher.dispatch({ type: "LAYER_POP" });
},
openUserProfile: (user: User) => {
openUserProfile(user.id);
},
});

View file

@ -1,3 +0,0 @@
[class*="usersList_"] [class*="text_"] {
user-select: text !important;
}