Fix Nitro Themes with FakeNitro (#639)

main
Nuckyz 2 years ago committed by GitHub
parent 0ba3e9f469
commit e29bbf73aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,11 +22,12 @@ import { Devs } from "@utils/constants";
import { ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
import { getCurrentGuild } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { findByCodeLazy, findByPropsLazy } from "@webpack";
import { findByCodeLazy, findByPropsLazy, findStoreLazy } from "@webpack";
import { ChannelStore, PermissionStore, UserStore } from "@webpack/common";
const DRAFT_TYPE = 0;
const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR");
const UserSettingsProtoStore = findStoreLazy("UserSettingsProtoStore");
const USE_EXTERNAL_EMOJIS = 1n << 18n;
const USE_EXTERNAL_STICKERS = 1n << 37n;
@ -148,6 +149,19 @@ export default definePlugin({
match: /canUseClientThemes:function\(\i\){/,
replace: "$&return true;"
}
},
{
find: '.displayName="UserSettingsProtoStore"',
replacement: [
{
match: /CONNECTION_OPEN:function\((\i)\){/,
replace: (m, props) => `${m}$self.handleProtoChange(${props}.userSettingsProto,${props}.user);`
},
{
match: /=(\i)\.local;/,
replace: (m, props) => `${m}${props}.local||$self.handleProtoChange(${props}.settings.proto);`
}
]
}
],
@ -196,6 +210,21 @@ export default definePlugin({
return (UserStore.getCurrentUser().premiumType ?? 0) > 1;
},
handleProtoChange(proto: any, user: any) {
const premiumType = user?.premium_type ?? UserStore.getCurrentUser().premiumType ?? 0;
if (premiumType === 0) {
const themeId = UserSettingsProtoStore.settings.appearance?.clientThemeSettings?.backgroundGradientPresetId?.value;
if (themeId != null) {
proto.appearance ??= {};
proto.appearance.clientThemeSettings ??= {};
proto.appearance.clientThemeSettings.backgroundGradientPresetId ??= {};
proto.appearance.clientThemeSettings.backgroundGradientPresetId.value = themeId;
}
}
},
hasPermissionToUseExternalEmojis(channelId: string) {
const channel = ChannelStore.getChannel(channelId);

Loading…
Cancel
Save