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[];
|
||||
|
||||
// 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];
|
||||
if (id == null) continue;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "UserProfileStore",
|
||||
replacement: {
|
||||
match: /(?<=getUserProfile\(\i\){return )(\i\[\i\])/,
|
||||
match: /(?<=getUserProfile\(\i\){return )(.+?)(?=})/,
|
||||
replace: "$self.colorDecodeHook($1)"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { ExpandableHeader } from "@components/ExpandableHeader";
|
||||
import { proxyLazy } from "@utils/lazy";
|
||||
import { classes } from "@utils/misc";
|
||||
import { findByProps } from "@webpack";
|
||||
import { i18n, PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/common";
|
||||
|
@ -36,13 +35,11 @@ interface UserPermission {
|
|||
|
||||
type UserPermissions = Array<UserPermission>;
|
||||
|
||||
const RoleClasses1 = findByProps("roles", "rolePill", "rolePillBorder");
|
||||
const RoleClasses2 = findByProps("roleCircle", "dotBorderBase", "dotBorderColor");
|
||||
const RoleClasses3 = findByProps("roleNameOverflow", "root", "roleName", "roleRemoveButton");
|
||||
const RoleRootClasses = findByProps("root", "showMoreButton", "collapseButton");
|
||||
const RoleClasses = findByProps("role", "roleCircle", "roleName");
|
||||
const RoleBorderClasses = findByProps("roleCircle", "dot", "dotBorderColor");
|
||||
|
||||
const Classes = proxyLazy(() => Object.assign({}, RoleClasses1, RoleClasses2, RoleClasses3));
|
||||
|
||||
function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen = false }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; forceOpen?: boolean; }) {
|
||||
function UserPermissionsComponent({ guild, guildMember, forceOpen = false }: { guild: Guild; guildMember: GuildMember; forceOpen?: boolean; }) {
|
||||
const stns = settings.use(["permissionsSortOrder"]);
|
||||
|
||||
const [rolePermissions, userPermissions] = useMemo(() => {
|
||||
|
@ -90,8 +87,6 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
|||
return [rolePermissions, userPermissions];
|
||||
}, [stns.permissionsSortOrder]);
|
||||
|
||||
const { root, role, roleRemoveButton, roleNameOverflow, roles, rolePill, rolePillBorder, roleCircle, roleName } = Classes;
|
||||
|
||||
return (
|
||||
<ExpandableHeader
|
||||
forceOpen={forceOpen}
|
||||
|
@ -129,18 +124,18 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
|||
</Tooltip>)
|
||||
]}>
|
||||
{userPermissions.length > 0 && (
|
||||
<div className={classes(root, roles)}>
|
||||
<div className={classes(RoleRootClasses.root)}>
|
||||
{userPermissions.map(({ permission, roleColor }) => (
|
||||
<div className={classes(role, rolePill, showBorder ? rolePillBorder : null)}>
|
||||
<div className={roleRemoveButton}>
|
||||
<div className={classes(RoleClasses.role)}>
|
||||
<div className={RoleClasses.roleRemoveButton}>
|
||||
<span
|
||||
className={roleCircle}
|
||||
className={classes(RoleBorderClasses.roleCircle, RoleClasses.roleCircle)}
|
||||
style={{ backgroundColor: roleColor }}
|
||||
/>
|
||||
</div>
|
||||
<div className={roleName}>
|
||||
<div className={RoleClasses.roleName}>
|
||||
<Text
|
||||
className={roleNameOverflow}
|
||||
className={RoleClasses.roleNameOverflow}
|
||||
variant="text-xs/medium"
|
||||
>
|
||||
{permission}
|
||||
|
|
|
@ -184,7 +184,7 @@ export default definePlugin({
|
|||
align="center"
|
||||
renderPopout={() => (
|
||||
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
||||
<UserPermissions guild={guild} guildMember={guildMember} showBorder forceOpen />
|
||||
<UserPermissions guild={guild} guildMember={guildMember} forceOpen />
|
||||
</Dialog>
|
||||
)}
|
||||
>
|
||||
|
|
|
@ -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];
|
||||
},
|
||||
|
|
|
@ -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(?!<isMultiUserDM.{0,50})/,
|
||||
|
|
Loading…
Reference in a new issue