Merge branch 'dev' into immediate-finds-modules-proxy
This commit is contained in:
commit
4a9f258e34
|
@ -127,7 +127,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 String(wreq.u).matchAll(/(?:"([\deE]+?)")|(?:([\deE]+?):)/g)) {
|
for (const currentMatch of String(wreq.u).matchAll(/(?:"([\deE]+?)"(?![,}]))|(?:([\deE]+?):)/g)) {
|
||||||
const id = currentMatch[1] ?? currentMatch[2];
|
const id = currentMatch[1] ?? currentMatch[2];
|
||||||
if (id == null) continue;
|
if (id == null) continue;
|
||||||
|
|
||||||
|
|
|
@ -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)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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 });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { ExpandableHeader } from "@components/ExpandableHeader";
|
import { ExpandableHeader } from "@components/ExpandableHeader";
|
||||||
import { proxyLazy } from "@utils/lazy";
|
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { findByProps } from "@webpack";
|
import { findByProps } from "@webpack";
|
||||||
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
||||||
|
@ -36,13 +35,11 @@ interface UserPermission {
|
||||||
|
|
||||||
type UserPermissions = Array<UserPermission>;
|
type UserPermissions = Array<UserPermission>;
|
||||||
|
|
||||||
const RoleClasses1 = findByProps("roles", "rolePill", "rolePillBorder");
|
const RoleRootClasses = findByProps("root", "showMoreButton", "collapseButton");
|
||||||
const RoleClasses2 = findByProps("roleCircle", "dotBorderBase", "dotBorderColor");
|
const RoleClasses = findByProps("role", "roleCircle", "roleName");
|
||||||
const RoleClasses3 = findByProps("roleNameOverflow", "root", "roleName", "roleRemoveButton");
|
const RoleBorderClasses = findByProps("roleCircle", "dot", "dotBorderColor");
|
||||||
|
|
||||||
const Classes = proxyLazy(() => Object.assign({}, RoleClasses1, RoleClasses2, RoleClasses3));
|
function UserPermissionsComponent({ guild, guildMember, forceOpen = false }: { guild: Guild; guildMember: GuildMember; forceOpen?: boolean; }) {
|
||||||
|
|
||||||
function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen = false }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; forceOpen?: boolean; }) {
|
|
||||||
const stns = settings.use(["permissionsSortOrder"]);
|
const stns = settings.use(["permissionsSortOrder"]);
|
||||||
|
|
||||||
const [rolePermissions, userPermissions] = useMemo(() => {
|
const [rolePermissions, userPermissions] = useMemo(() => {
|
||||||
|
@ -90,8 +87,6 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
||||||
return [rolePermissions, userPermissions];
|
return [rolePermissions, userPermissions];
|
||||||
}, [stns.permissionsSortOrder]);
|
}, [stns.permissionsSortOrder]);
|
||||||
|
|
||||||
const { root, role, roleRemoveButton, roleNameOverflow, roles, rolePill, rolePillBorder, roleCircle, roleName } = Classes;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExpandableHeader
|
<ExpandableHeader
|
||||||
forceOpen={forceOpen}
|
forceOpen={forceOpen}
|
||||||
|
@ -129,18 +124,18 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
||||||
</Tooltip>)
|
</Tooltip>)
|
||||||
]}>
|
]}>
|
||||||
{userPermissions.length > 0 && (
|
{userPermissions.length > 0 && (
|
||||||
<div className={classes(root, roles)}>
|
<div className={classes(RoleRootClasses.root)}>
|
||||||
{userPermissions.map(({ permission, roleColor }) => (
|
{userPermissions.map(({ permission, roleColor }) => (
|
||||||
<div className={classes(role, rolePill, showBorder ? rolePillBorder : null)}>
|
<div className={classes(RoleClasses.role)}>
|
||||||
<div className={roleRemoveButton}>
|
<div className={RoleClasses.roleRemoveButton}>
|
||||||
<span
|
<span
|
||||||
className={roleCircle}
|
className={classes(RoleBorderClasses.roleCircle, RoleClasses.roleCircle)}
|
||||||
style={{ backgroundColor: roleColor }}
|
style={{ backgroundColor: roleColor }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={roleName}>
|
<div className={RoleClasses.roleName}>
|
||||||
<Text
|
<Text
|
||||||
className={roleNameOverflow}
|
className={RoleClasses.roleNameOverflow}
|
||||||
variant="text-xs/medium"
|
variant="text-xs/medium"
|
||||||
>
|
>
|
||||||
{permission}
|
{permission}
|
||||||
|
|
|
@ -184,7 +184,7 @@ export default definePlugin({
|
||||||
align="center"
|
align="center"
|
||||||
renderPopout={() => (
|
renderPopout={() => (
|
||||||
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
||||||
<UserPermissions guild={guild} guildMember={guildMember} showBorder forceOpen />
|
<UserPermissions guild={guild} guildMember={guildMember} forceOpen />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -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];
|
||||||
},
|
},
|
||||||
|
|
|
@ -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})/,
|
||||||
|
|
Loading…
Reference in a new issue