aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/fakeNitro.ts
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2023-02-17 23:32:02 -0300
committerGitHub <noreply@github.com>2023-02-18 03:32:02 +0100
commite14ec96e214f60058155560717b01a553f58c2c1 (patch)
tree4360bd77bf6ae37c2fad412f4233e61f3506320a /src/plugins/fakeNitro.ts
parentff1f3376998bcf58a396f43a92f4e5395f69876c (diff)
downloadVencord-e14ec96e214f60058155560717b01a553f58c2c1.tar.gz
Vencord-e14ec96e214f60058155560717b01a553f58c2c1.tar.bz2
Vencord-e14ec96e214f60058155560717b01a553f58c2c1.zip
feat(FakeNitro): Bypass client themes and fixes (#504)
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/fakeNitro.ts')
-rw-r--r--src/plugins/fakeNitro.ts84
1 files changed, 57 insertions, 27 deletions
diff --git a/src/plugins/fakeNitro.ts b/src/plugins/fakeNitro.ts
index dd8ff19..22ffb80 100644
--- a/src/plugins/fakeNitro.ts
+++ b/src/plugins/fakeNitro.ts
@@ -22,11 +22,14 @@ import { Devs } from "@utils/constants";
import { ApngDisposeOp, getGifEncoder, importApngJs } from "@utils/dependencies";
import definePlugin, { OptionType } from "@utils/types";
import { findByCodeLazy, findByPropsLazy } from "@webpack";
-import { ChannelStore, UserStore } from "@webpack/common";
+import { ChannelStore, PermissionStore, UserStore } from "@webpack/common";
const DRAFT_TYPE = 0;
const promptToUpload = findByCodeLazy("UPLOAD_FILE_LIMIT_ERROR");
+const USE_EXTERNAL_EMOJIS = 1n << 18n;
+const USE_EXTERNAL_STICKERS = 1n << 37n;
+
enum EmojiIntentions {
REACTION = 0,
STATUS = 1,
@@ -69,8 +72,8 @@ migratePluginSettings("FakeNitro", "NitroBypass");
export default definePlugin({
name: "FakeNitro",
- authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity],
- description: "Allows you to stream in nitro quality and send fake emojis/stickers.",
+ authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.obscurity, Devs.captain],
+ description: "Allows you to stream in nitro quality, send fake emojis/stickers and use client themes.",
dependencies: ["MessageEventsAPI"],
patches: [
@@ -79,12 +82,16 @@ export default definePlugin({
predicate: () => Settings.plugins.FakeNitro.enableEmojiBypass === true,
replacement: [
{
- match: /(?<=(?<intention>\i)=\i\.intention.+?\.(?:canUseEmojisEverywhere|canUseAnimatedEmojis)\(\i)(?=\))/g,
- replace: ",$<intention>"
+ match: /(?<=(?<intention>\i)=\i\.intention)/,
+ replace: ",fakeNitroIntention=$<intention>"
+ },
+ {
+ match: /(?<=\.(?:canUseEmojisEverywhere|canUseAnimatedEmojis)\(\i)(?=\))/g,
+ replace: ",fakeNitroIntention"
},
{
- match: /(?<=,\i=)\i\.\i\.can\(\i\.\i\.USE_EXTERNAL_EMOJIS,\i\)(?=;)/,
- replace: "true"
+ match: /(?<=&&!\i&&)!(?<canUseExternal>\i)(?=\)return \i\.\i\.DISALLOW_EXTERNAL;)/,
+ replace: `(!$<canUseExternal>&&![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention))`
}
]
},
@@ -92,12 +99,12 @@ export default definePlugin({
find: "canUseAnimatedEmojis:function",
predicate: () => Settings.plugins.FakeNitro.enableEmojiBypass === true,
replacement: {
- match: /(?<=(?:canUseEmojisEverywhere|canUseAnimatedEmojis):function\(\i)\){/g,
- replace: `,fakeNitroIntention){return fakeNitroIntention===undefined||[${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention);`
+ match: /(?<=(?:canUseEmojisEverywhere|canUseAnimatedEmojis):function\((?<user>\i))\){(?<premiumCheck>.+?\))/g,
+ replace: `,fakeNitroIntention){$<premiumCheck>||fakeNitroIntention===undefined||[${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)`
}
},
{
- find: "canUseAnimatedEmojis:function",
+ find: "canUseStickersEverywhere:function",
predicate: () => Settings.plugins.FakeNitro.enableStickerBypass === true,
replacement: {
match: /canUseStickersEverywhere:function\(.+?\{/,
@@ -113,7 +120,7 @@ export default definePlugin({
}
},
{
- find: "canUseAnimatedEmojis:function",
+ find: "canStreamHighQuality:function",
predicate: () => Settings.plugins.FakeNitro.enableStreamQualityBypass === true,
replacement: [
"canUseHighVideoUploadQuality",
@@ -134,6 +141,13 @@ export default definePlugin({
replace: ""
}
},
+ {
+ find: "canUseClientThemes:function",
+ replacement: {
+ match: /(?<=canUseClientThemes:function\(\i\){)/,
+ replace: "return true;"
+ }
+ }
],
options: {
@@ -181,6 +195,22 @@ export default definePlugin({
return (UserStore.getCurrentUser().premiumType ?? 0) > 1;
},
+ hasPermissionToUseExternalEmojis(channelId: string) {
+ const channel = ChannelStore.getChannel(channelId);
+
+ if (!channel || channel.isDM() || channel.isGroupDM() || channel.isMultiUserDM()) return true;
+
+ return PermissionStore.can(USE_EXTERNAL_EMOJIS, channel);
+ },
+
+ hasPermissionToUseExternalStickers(channelId: string) {
+ const channel = ChannelStore.getChannel(channelId);
+
+ if (!channel || channel.isDM() || channel.isGroupDM() || channel.isMultiUserDM()) return true;
+
+ return PermissionStore.can(USE_EXTERNAL_STICKERS, channel);
+ },
+
getStickerLink(stickerId: string) {
return `https://media.discordapp.net/stickers/${stickerId}.png?size=${Settings.plugins.FakeNitro.stickerSize}`;
},
@@ -265,7 +295,7 @@ export default definePlugin({
if (!sticker)
break stickerBypass;
- if (sticker.available !== false && (this.canUseStickers || (sticker as GuildSticker)?.guild_id === guildId))
+ if (sticker.available !== false && ((this.canUseStickers && this.hasPermissionToUseExternalStickers(channelId)) || (sticker as GuildSticker)?.guild_id === guildId))
break stickerBypass;
let link = this.getStickerLink(sticker.id);
@@ -288,7 +318,7 @@ export default definePlugin({
}
}
- if (!this.canUseEmotes && settings.enableEmojiBypass) {
+ if ((!this.canUseEmotes || !this.hasPermissionToUseExternalEmojis(channelId)) && settings.enableEmojiBypass) {
for (const emoji of messageObj.validNonShortcutEmojis) {
if (!emoji.require_colons) continue;
if (emoji.guildId === guildId && !emoji.animated) continue;
@@ -304,22 +334,22 @@ export default definePlugin({
return { cancel: false };
});
- if (!this.canUseEmotes && settings.enableEmojiBypass) {
- this.preEdit = addPreEditListener((_, __, messageObj) => {
- const { guildId } = this;
+ this.preEdit = addPreEditListener((channelId, __, messageObj) => {
+ if (this.canUseEmotes && this.hasPermissionToUseExternalEmojis(channelId)) return;
- for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) {
- const emoji = EmojiStore.getCustomEmojiById(emojiId);
- if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
- if (!emoji.require_colons) continue;
+ const { guildId } = this;
- const url = emoji.url.replace(/\?size=\d+/, `?size=${Settings.plugins.FakeNitro.emojiSize}`);
- messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => {
- return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
- });
- }
- });
- }
+ for (const [emojiStr, _, emojiId] of messageObj.content.matchAll(/(?<!\\)<a?:(\w+):(\d+)>/ig)) {
+ const emoji = EmojiStore.getCustomEmojiById(emojiId);
+ if (emoji == null || (emoji.guildId === guildId && !emoji.animated)) continue;
+ if (!emoji.require_colons) continue;
+
+ const url = emoji.url.replace(/\?size=\d+/, `?size=${Settings.plugins.FakeNitro.emojiSize}`);
+ messageObj.content = messageObj.content.replace(emojiStr, (match, offset, origStr) => {
+ return `${getWordBoundary(origStr, offset - 1)}${url}${getWordBoundary(origStr, offset + match.length)}`;
+ });
+ }
+ });
},
stop() {