aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2023-03-21 06:03:28 -0300
committerGitHub <noreply@github.com>2023-03-21 09:03:28 +0000
commite29bbf73aa789f5560e37eaee0a146facd69e354 (patch)
tree38d1960928ff237af86326c635d466d045cb28d5
parent0ba3e9f469711e56abae42a07e63dd4474aac5e3 (diff)
downloadVencord-e29bbf73aa789f5560e37eaee0a146facd69e354.tar.gz
Vencord-e29bbf73aa789f5560e37eaee0a146facd69e354.tar.bz2
Vencord-e29bbf73aa789f5560e37eaee0a146facd69e354.zip
Fix Nitro Themes with FakeNitro (#639)
-rw-r--r--src/plugins/fakeNitro.ts31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts
index bba6aca..7e583d7 100644
--- a/src/plugins/fakeNitro.ts
+++ b/src/plugins/fakeNitro.ts
@@ -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);