Update EditUsers.plugin.js

This commit is contained in:
Mirco Wittrien 2024-06-30 19:04:26 +02:00
parent f8b7eef5cf
commit 6fdeafe5f7
1 changed files with 44 additions and 74 deletions

View File

@ -2,7 +2,7 @@
* @name EditUsers
* @author DevilBro
* @authorId 278543574059057154
* @version 4.8.9
* @version 4.9.0
* @description Allows you to locally edit Users
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -128,13 +128,9 @@ module.exports = (_ => {
"SearchPopoutOption",
"ThreadMessageAccessoryMessage",
"UserBanner",
"UserBannerMask",
"UserHeaderAvatar",
"UserHeaderUsername",
"UserInfo",
"UsernameSection",
"UserPopoutAvatar",
"UserProfile",
"UserProfileHeader",
"UserProfileUsername",
"UserSummaryItem",
"VoiceUser"
],
@ -166,9 +162,8 @@ module.exports = (_ => {
"ThreadEmptyMessageAuthor",
"TypingUsers",
"UserMention",
"UsernameSection",
"UserProfileMutualFriends",
"UserProfileUsername",
"UserBanner",
"UserHeaderUsername",
"VoiceUser"
]
};
@ -196,6 +191,12 @@ module.exports = (_ => {
${BDFDB.dotCNS.peoplesuserhovered + BDFDB.dotCN.peoplesdiscriminator} {
display: block;
}
${BDFDB.dotCN.userheadernickname}:has(span) {
text-decoration: unset !important;
}
${BDFDB.dotCN.userheadernickname}:hover > span:first-child {
text-decoration: underline !important;
}
${BDFDB.dotCN.message} span[style*="--edited-user-color-gradient"] ${BDFDB.dotCN.messageusername} {
background-image: var(--edited-user-color-gradient) !important;
color: transparent !important;
@ -295,6 +296,14 @@ module.exports = (_ => {
return e.callOriginalMethod();
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.UserBannerUtils, "getBanner", {after: e => {
let data = e.returnValue && e.methodArguments[0].displayProfile && changedUsers[e.methodArguments[0].displayProfile.userId];
if (data) {
if (data.removeBanner) e.returnValue.bannerSrc = null;
else if (data.banner) e.returnValue.bannerSrc = data.banner;
}
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.MemberDisplayUtils, "getUserProfile", {after: e => {
if (!e.returnValue || !changedUsers[e.methodArguments[0]] || !changedUsers[e.methodArguments[0]].color5 && !changedUsers[e.methodArguments[0]].color6 && !changedUsers[e.methodArguments[0]].color7) return;
let newProfileObject = BDFDB.ObjectUtils.copy(e.returnValue);
@ -523,12 +532,7 @@ module.exports = (_ => {
let change = false, guildId = null;
let tagClass = "";
if (e.instance.props.className) {
if (e.instance.props.className.indexOf(BDFDB.disCN.userpopoutheadertagwithnickname) > -1) {
change = this.settings.places.userPopout;
guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId();
tagClass = BDFDB.disCNS.userpopoutheaderbottag + BDFDB.disCN.bottagnametag;
}
else if (e.instance.props.className.indexOf(BDFDB.disCN.guildsettingsinviteusername) > -1) {
if (e.instance.props.className.indexOf(BDFDB.disCN.guildsettingsinviteusername) > -1) {
change = this.settings.places.guildSettings;
}
else if (e.instance.props.className.indexOf(BDFDB.disCN.peoplesdiscordtag) > -1) {
@ -548,36 +552,30 @@ module.exports = (_ => {
processUserBanner (e) {
if (!e.instance.props.user || !changedUsers[e.instance.props.user.id]) return;
if (changedUsers[e.instance.props.user.id].removeBanner) {
e.instance.props.bannerSrc = null;
if (e.instance.props.displayProfile) e.instance.props.displayProfile.banner = null;
}
else if (changedUsers[e.instance.props.user.id].banner) {
e.instance.props.bannerSrc = changedUsers[e.instance.props.user.id].banner;
if (e.instance.props.displayProfile) {
e.instance.props.displayProfile = BDFDB.ObjectUtils.copy(e.instance.props.displayProfile);
e.instance.props.displayProfile.banner = changedUsers[e.instance.props.user.id].banner;
e.instance.props.displayProfile.premiumType = 2;
}
}
}
processUserBannerMask (e) {
if (!e.instance.props.user || !changedUsers[e.instance.props.user.id]) return;
if (changedUsers[e.instance.props.user.id].removeBanner) e.instance.props.isPremium = false;
else if (changedUsers[e.instance.props.user.id].banner) e.instance.props.isPremium = true;
}
processUserPopoutAvatar (e) {
if (!e.instance.props.user || !changedUsers[e.instance.props.user.id]) return;
if (this.settings.places.userPopout) e.instance.props.user = this.getUserData(e.instance.props.user.id, true, true);
if (e.instance.props.displayProfile) {
if (!e.returnvalue) {
if (changedUsers[e.instance.props.user.id].removeBanner) {
e.instance.props.hasBanner = false;
e.instance.props.displayProfile.banner = null;
}
else if (changedUsers[e.instance.props.user.id].banner) {
e.instance.props.hasBanner = true;
e.instance.props.displayProfile = BDFDB.ObjectUtils.copy(e.instance.props.displayProfile);
e.instance.props.displayProfile.banner = changedUsers[e.instance.props.user.id].banner;
e.instance.props.displayProfile.premiumType = 2;
}
}
else {
if (changedUsers[e.instance.props.user.id].removeBanner) e.returnvalue.props.isPremium = false;
else if (changedUsers[e.instance.props.user.id].banner) e.returnvalue.props.isPremium = true;
if (e.instance.props.displayProfile.themeColors) e.returnvalue.props.hasThemeColors = true;
else e.returnvalue.props.hasThemeColors = false;
}
}
processUserHeaderAvatar (e) {
if (!e.instance.props.user || !changedUsers[e.instance.props.user.id]) return;
if (this.settings.places.userPopout) e.instance.props.user = this.getUserData(e.instance.props.user.id, true, true);
if (e.instance.props.displayProfile) {
if (changedUsers[e.instance.props.user.id].removeBanner) e.instance.props.displayProfile.banner = null;
else if (changedUsers[e.instance.props.user.id].banner) {
e.instance.props.displayProfile = BDFDB.ObjectUtils.copy(e.instance.props.displayProfile);
e.instance.props.displayProfile.banner = changedUsers[e.instance.props.user.id].banner;
e.instance.props.displayProfile.premiumType = 2;
@ -585,8 +583,8 @@ module.exports = (_ => {
}
}
processUsernameSection (e) {
if (!this.settings.places.userPopout || !e.instance.props.user) return;
processUserHeaderUsername (e) {
if (!e.instance.props.user || e.instance.props.profileType == BDFDB.DiscordConstants.ProfileTypes.BITE_SIZE && !this.settings.places.userPopout || e.instance.props.profileType == BDFDB.DiscordConstants.ProfileTypes.FULL_SIZE && !this.settings.places.userProfile) return;
let data = changedUsers[e.instance.props.user.id];
if (!data) return;
if (!e.returnvalue) {
@ -595,12 +593,12 @@ module.exports = (_ => {
}
else {
if (data.color1 || data.tag) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutheadernickname]]});
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.userheadernickname]]});
if (index > -1) {
this.changeUserColor(children[index], e.instance.props.user.id);
if (!BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children = [children[index].props.children].flat(10);
this.injectBadge(children[index].props.children, e.instance.props.user.id, BDFDB.LibraryStores.SelectedGuildStore.getGuildId(), 2, {
tagClass: BDFDB.disCNS.userpopoutheaderbottag + BDFDB.disCN.bottagnametag,
tagClass: BDFDB.disCNS.userheaderbottag + BDFDB.disCN.bottagnametag,
inverted: typeof e.instance.getMode == "function" && e.instance.getMode() !== "Normal"
});
}
@ -608,34 +606,6 @@ module.exports = (_ => {
}
}
processUserProfile (e) {
if (e.instance.props.user && this.settings.places.userProfile) e.instance.props.user = this.getUserData(e.instance.props.user.id);
}
processUserProfileHeader (e) {
if (e.instance.props.user && this.settings.places.userProfile) e.instance.props.user = this.getUserData(e.instance.props.user.id);
}
processUserProfileUsername (e) {
if (!e.instance.props.user || !this.settings.places.userProfile) return;
if (!e.returnvalue) e.instance.props.user = this.getUserData(e.instance.props.user.id);
else {
let username = BDFDB.ReactUtils.findChild(e.returnvalue, {props: ["children", "style", "variant"]});
if (!username) return;
username.props.children = BDFDB.ReactUtils.createElement(BDFDB.ReactUtils.Fragment, {children: username.props.children});
this.changeUserColor(username.props.children, e.instance.props.user.id);
username.props.children = [username.props.children];
this.injectBadge(username.props.children, e.instance.props.user.id, BDFDB.LibraryStores.SelectedGuildStore.getGuildId(), 2, {
tagClass: BDFDB.disCN.bottagnametag
});
}
}
processUserProfileMutualFriends (e) {
if (!this.settings.places.userProfile || !e.returnvalue.props.children || !e.returnvalue.props.children.length) return;
for (let row of e.returnvalue.props.children) if (row && row.props && row.props.user) row.props.user = this.getUserData(row.props.user.id);
}
processUserInfo (e) {
if (!this.settings.places.friendList || !e.instance.props.user) return;
e.instance.props.user = this.getUserData(e.instance.props.user.id);