FakeNitro: Fix & rewrite emoji bypass patches
This commit is contained in:
		
							parent
							
								
									c5e554e48c
								
							
						
					
					
						commit
						0c50e153ef
					
				
					 1 changed files with 39 additions and 36 deletions
				
			
		| 
						 | 
					@ -54,16 +54,22 @@ const ClientThemeSettingsActionsCreators = proxyLazyWebpack(() => searchProtoCla
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const enum EmojiIntentions {
 | 
					const enum EmojiIntentions {
 | 
				
			||||||
    REACTION = 0,
 | 
					    REACTION,
 | 
				
			||||||
    STATUS = 1,
 | 
					    STATUS,
 | 
				
			||||||
    COMMUNITY_CONTENT = 2,
 | 
					    COMMUNITY_CONTENT,
 | 
				
			||||||
    CHAT = 3,
 | 
					    CHAT,
 | 
				
			||||||
    GUILD_STICKER_RELATED_EMOJI = 4,
 | 
					    GUILD_STICKER_RELATED_EMOJI,
 | 
				
			||||||
    GUILD_ROLE_BENEFIT_EMOJI = 5,
 | 
					    GUILD_ROLE_BENEFIT_EMOJI,
 | 
				
			||||||
    COMMUNITY_CONTENT_ONLY = 6,
 | 
					    COMMUNITY_CONTENT_ONLY,
 | 
				
			||||||
    SOUNDBOARD = 7
 | 
					    SOUNDBOARD,
 | 
				
			||||||
 | 
					    VOICE_CHANNEL_TOPIC,
 | 
				
			||||||
 | 
					    GIFT,
 | 
				
			||||||
 | 
					    AUTO_SUGGESTION,
 | 
				
			||||||
 | 
					    POLLS
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const IS_BYPASSEABLE_INTENTION = `[${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const enum StickerType {
 | 
					const enum StickerType {
 | 
				
			||||||
    PNG = 1,
 | 
					    PNG = 1,
 | 
				
			||||||
    APNG = 2,
 | 
					    APNG = 2,
 | 
				
			||||||
| 
						 | 
					@ -198,37 +204,43 @@ export default definePlugin({
 | 
				
			||||||
    patches: [
 | 
					    patches: [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            find: ".PREMIUM_LOCKED;",
 | 
					            find: ".PREMIUM_LOCKED;",
 | 
				
			||||||
 | 
					            group: true,
 | 
				
			||||||
            predicate: () => settings.store.enableEmojiBypass,
 | 
					            predicate: () => settings.store.enableEmojiBypass,
 | 
				
			||||||
            replacement: [
 | 
					            replacement: [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    // Create a variable for the intention of listing the emoji
 | 
					                    // Create a variable for the intention of using the emoji
 | 
				
			||||||
                    match: /(?<=,intention:(\i).+?;)/,
 | 
					                    match: /(?<=\.USE_EXTERNAL_EMOJIS.+?;)(?<=intention:(\i).+?)/,
 | 
				
			||||||
                    replace: (_, intention) => `let fakeNitroIntention=${intention};`
 | 
					                    replace: (_, intention) => `const fakeNitroIntention=${intention};`
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    // Send the intention of listing the emoji to the nitro permission check functions
 | 
					                    // Disallow the emoji for external if the intention doesn't allow it
 | 
				
			||||||
                    match: /\.(?:canUseEmojisEverywhere|canUseAnimatedEmojis)\(\i(?=\))/g,
 | 
					                    match: /&&!\i&&!\i(?=\)return \i\.\i\.DISALLOW_EXTERNAL;)/,
 | 
				
			||||||
                    replace: '$&,typeof fakeNitroIntention!=="undefined"?fakeNitroIntention:void 0'
 | 
					                    replace: m => `${m}&&!${IS_BYPASSEABLE_INTENTION}`
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    // Disallow the emoji if the intention doesn't allow it
 | 
					                    // Disallow the emoji for unavailable if the intention doesn't allow it
 | 
				
			||||||
                    match: /(&&!\i&&)!(\i)(?=\)return \i\.\i\.DISALLOW_EXTERNAL;)/,
 | 
					                    match: /!\i\.available(?=\)return \i\.\i\.GUILD_SUBSCRIPTION_UNAVAILABLE;)/,
 | 
				
			||||||
                    replace: (_, rest, canUseExternal) => `${rest}(!${canUseExternal}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)))`
 | 
					                    replace: m => `${m}&&!${IS_BYPASSEABLE_INTENTION}`
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    // Make the emoji always available if the intention allows it
 | 
					                    // Disallow the emoji for premium locked if the intention doesn't allow it
 | 
				
			||||||
                    match: /if\(!\i\.available/,
 | 
					                    match: /!\i\.\i\.canUseEmojisEverywhere\(\i\)/,
 | 
				
			||||||
                    replace: m => `${m}&&(typeof fakeNitroIntention==="undefined"||![${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention))`
 | 
					                    replace: m => `(${m}&&!${IS_BYPASSEABLE_INTENTION})`
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    // Allow animated emojis to be used if the intention allows it
 | 
				
			||||||
 | 
					                    match: /(?<=\|\|)\i\.\i\.canUseAnimatedEmojis\(\i\)/,
 | 
				
			||||||
 | 
					                    replace: m => `(${m}||${IS_BYPASSEABLE_INTENTION})`
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ]
 | 
					            ]
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        // Allow emojis and animated emojis to be sent everywhere
 | 
					        // Allows the usage of subscription-locked emojis
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            find: "canUseAnimatedEmojis:function",
 | 
					            find: "isUnusableRoleSubscriptionEmoji:function",
 | 
				
			||||||
            predicate: () => settings.store.enableEmojiBypass,
 | 
					 | 
				
			||||||
            replacement: {
 | 
					            replacement: {
 | 
				
			||||||
                match: /((?:canUseEmojisEverywhere|canUseAnimatedEmojis):function\(\i)\){(.+?\))(?=})/g,
 | 
					                match: /isUnusableRoleSubscriptionEmoji:function/,
 | 
				
			||||||
                replace: (_, rest, premiumCheck) => `${rest},fakeNitroIntention){${premiumCheck}||fakeNitroIntention==null||[${EmojiIntentions.CHAT},${EmojiIntentions.GUILD_STICKER_RELATED_EMOJI}].includes(fakeNitroIntention)`
 | 
					                // Replace the original export with a func that always returns false and alias the original
 | 
				
			||||||
 | 
					                replace: "isUnusableRoleSubscriptionEmoji:()=>()=>false,isUnusableRoleSubscriptionEmojiOriginal:function"
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        // Allow stickers to be sent everywhere
 | 
					        // Allow stickers to be sent everywhere
 | 
				
			||||||
| 
						 | 
					@ -242,10 +254,10 @@ export default definePlugin({
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        // Make stickers always available
 | 
					        // Make stickers always available
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            find: "\"SENDABLE\"",
 | 
					            find: '"SENDABLE"',
 | 
				
			||||||
            predicate: () => settings.store.enableStickerBypass,
 | 
					            predicate: () => settings.store.enableStickerBypass,
 | 
				
			||||||
            replacement: {
 | 
					            replacement: {
 | 
				
			||||||
                match: /(\w+)\.available\?/,
 | 
					                match: /\i\.available\?/,
 | 
				
			||||||
                replace: "true?"
 | 
					                replace: "true?"
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
| 
						 | 
					@ -408,15 +420,6 @@ export default definePlugin({
 | 
				
			||||||
                match: /canUseCustomNotificationSounds:function\(\i\){/,
 | 
					                match: /canUseCustomNotificationSounds:function\(\i\){/,
 | 
				
			||||||
                replace: "$&return true;"
 | 
					                replace: "$&return true;"
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        },
 | 
					 | 
				
			||||||
        // Allows the usage of subscription-locked emojis
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            find: "isUnusableRoleSubscriptionEmoji:function",
 | 
					 | 
				
			||||||
            replacement: {
 | 
					 | 
				
			||||||
                match: /isUnusableRoleSubscriptionEmoji:function/,
 | 
					 | 
				
			||||||
                // replace the original export with a func that always returns false and alias the original
 | 
					 | 
				
			||||||
                replace: "isUnusableRoleSubscriptionEmoji:()=>()=>false,isUnusableRoleSubscriptionEmojiOriginal:function"
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue