diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index d3484bd9..73a89504 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -134,7 +134,7 @@ export async function loadLazyChunks() { const allChunks = [] as number[]; // 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]; if (id == null) continue; diff --git a/src/plugins/fakeProfileThemes/index.tsx b/src/plugins/fakeProfileThemes/index.tsx index ab240837..708c961a 100644 --- a/src/plugins/fakeProfileThemes/index.tsx +++ b/src/plugins/fakeProfileThemes/index.tsx @@ -121,7 +121,7 @@ export default definePlugin({ { find: "UserProfileStore", replacement: { - match: /(?<=getUserProfile\(\i\){return )(\i\[\i\])/, + match: /(?<=getUserProfile\(\i\){return )(.+?)(?=})/, replace: "$self.colorDecodeHook($1)" } }, diff --git a/src/plugins/noProfileThemes/index.ts b/src/plugins/noProfileThemes/index.ts index 2cb83cc7..d4737d43 100644 --- a/src/plugins/noProfileThemes/index.ts +++ b/src/plugins/noProfileThemes/index.ts @@ -18,27 +18,36 @@ import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; +import { UserStore } from "@webpack/common"; +import virtualMerge from "virtual-merge"; export default definePlugin({ name: "NoProfileThemes", - description: "Completely removes Nitro profile themes", + description: "Completely removes Nitro profile themes from everyone but yourself", authors: [Devs.TheKodeToad], 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(){", replacement: { 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 }); + } }); diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index fbc75f52..788a79ae 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -57,14 +57,7 @@ export default definePlugin({ settings, patches: [ { - find: ".NITRO_BANNER,", - replacement: { - match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/, - replace: "&&$self.shouldShowBadge(arguments[0])$&" - } - }, - { - find: ".banner)==null", + find: '.banner)==null?"COMPLETE"', replacement: { match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/, replace: "$self.patchBannerUrl(arguments[0])||$&" @@ -109,10 +102,6 @@ export default definePlugin({ 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) { return !!this.data?.users[userId]; }, diff --git a/src/plugins/viewIcons/index.tsx b/src/plugins/viewIcons/index.tsx index 38d77554..c154de63 100644 --- a/src/plugins/viewIcons/index.tsx +++ b/src/plugins/viewIcons/index.tsx @@ -193,16 +193,13 @@ export default definePlugin({ all: true }, // Banners - ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({ - find, + { + find: 'backgroundColor:"COMPLETE"', replacement: { - // style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl, - match: /style:\{(?=backgroundImage:(null!=\i)\?"url\("\.concat\((\i),)/, - 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,' + match: /(\.banner,.+?),style:{(?=.+?backgroundImage:null!=(\i)\?"url\("\.concat\(\2,)/, + replace: (_, rest, bannerSrc) => `${rest},onClick:()=>${bannerSrc}!=null&&$self.openImage(${bannerSrc}),style:{cursor:${bannerSrc}!=null?"pointer":void 0,` } - })), + }, // Group DMs top small & large icon { find: /\.recipients\.length>=2(?!