Fix ViewIcons and NoProfileThemes

This commit is contained in:
Nuckyz 2024-08-23 03:02:04 -03:00
parent 2e81b9aeba
commit ed9b28febf
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
5 changed files with 29 additions and 34 deletions

View file

@ -134,7 +134,7 @@ export async function loadLazyChunks() {
const allChunks = [] as number[]; const allChunks = [] as number[];
// Matches "id" or id: // Matches "id" or id:
for (const currentMatch of wreq!.u.toString().matchAll(/(?:"([\deE]+?)")|(?:([\deE]+?):)/g)) { for (const currentMatch of wreq!.u.toString().matchAll(/(?:"([\deE]+?)"(?![,}]))|(?:([\deE]+?):)/g)) {
const id = currentMatch[1] ?? currentMatch[2]; const id = currentMatch[1] ?? currentMatch[2];
if (id == null) continue; if (id == null) continue;

View file

@ -121,7 +121,7 @@ export default definePlugin({
{ {
find: "UserProfileStore", find: "UserProfileStore",
replacement: { replacement: {
match: /(?<=getUserProfile\(\i\){return )(\i\[\i\])/, match: /(?<=getUserProfile\(\i\){return )(.+?)(?=})/,
replace: "$self.colorDecodeHook($1)" replace: "$self.colorDecodeHook($1)"
} }
}, },

View file

@ -18,27 +18,36 @@
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
import { UserStore } from "@webpack/common";
import virtualMerge from "virtual-merge";
export default definePlugin({ export default definePlugin({
name: "NoProfileThemes", name: "NoProfileThemes",
description: "Completely removes Nitro profile themes", description: "Completely removes Nitro profile themes from everyone but yourself",
authors: [Devs.TheKodeToad], authors: [Devs.TheKodeToad],
patches: [ patches: [
{
find: ".NITRO_BANNER,",
replacement: {
// = isPremiumAtLeast(user.premiumType, TIER_2)
match: /=(?=\i\.\i\.isPremiumAtLeast\(null==(\i))/,
// = user.banner && isPremiumAtLeast(user.premiumType, TIER_2)
replace: "=(arguments[0]?.bannerSrc||$1?.banner)&&"
}
},
{ {
find: "hasThemeColors(){", find: "hasThemeColors(){",
replacement: { replacement: {
match: /get canUsePremiumProfileCustomization\(\){return /, match: /get canUsePremiumProfileCustomization\(\){return /,
replace: "$&false &&" replace: "$&$self.isCurrentUser(this.userId)&&"
}
},
{
find: "UserProfileStore",
replacement: {
match: /(?<=getUserProfile\(\i\){return )(.+?)(?=})/,
replace: "$self.removeProfileThemes($1)"
} }
} }
] ],
isCurrentUser: (userId: string) => userId === UserStore.getCurrentUser()?.id,
removeProfileThemes: (displayProfile: any) => {
if (displayProfile == null) return displayProfile;
return displayProfile.userId === UserStore.getCurrentUser()?.id
? displayProfile
: virtualMerge(displayProfile, { banner: undefined, profileEffectId: undefined });
}
}); });

View file

@ -57,14 +57,7 @@ export default definePlugin({
settings, settings,
patches: [ patches: [
{ {
find: ".NITRO_BANNER,", find: '.banner)==null?"COMPLETE"',
replacement: {
match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/,
replace: "&&$self.shouldShowBadge(arguments[0])$&"
}
},
{
find: ".banner)==null",
replacement: { replacement: {
match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/, match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/,
replace: "$self.patchBannerUrl(arguments[0])||$&" replace: "$self.patchBannerUrl(arguments[0])||$&"
@ -109,10 +102,6 @@ export default definePlugin({
if (this.userHasBackground(displayProfile?.userId)) return this.getImageUrl(displayProfile?.userId); if (this.userHasBackground(displayProfile?.userId)) return this.getImageUrl(displayProfile?.userId);
}, },
shouldShowBadge({ displayProfile, user }: any) {
return displayProfile?.banner && (!this.userHasBackground(user.id) || settings.store.nitroFirst);
},
userHasBackground(userId: string) { userHasBackground(userId: string) {
return !!this.data?.users[userId]; return !!this.data?.users[userId];
}, },

View file

@ -193,16 +193,13 @@ export default definePlugin({
all: true all: true
}, },
// Banners // Banners
...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ {
find, find: 'backgroundColor:"COMPLETE"',
replacement: { replacement: {
// style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl, match: /(\.banner,.+?),style:{(?=.+?backgroundImage:null!=(\i)\?"url\("\.concat\(\2,)/,
match: /style:\{(?=backgroundImage:(null!=\i)\?"url\("\.concat\((\i),)/, replace: (_, rest, bannerSrc) => `${rest},onClick:()=>${bannerSrc}!=null&&$self.openImage(${bannerSrc}),style:{cursor:${bannerSrc}!=null?"pointer":void 0,`
replace:
// onClick: () => shouldShowBanner && ev.target.style.backgroundImage && openImage(bannerUrl), style: { cursor: shouldShowBanner ? "pointer" : void 0,
'onClick:ev=>$1&&ev.target.style.backgroundImage&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
} }
})), },
// Group DMs top small & large icon // Group DMs top small & large icon
{ {
find: /\.recipients\.length>=2(?!<isMultiUserDM.{0,50})/, find: /\.recipients\.length>=2(?!<isMultiUserDM.{0,50})/,