From 6081da18e038983ad86ccf6b83f8064230237d84 Mon Sep 17 00:00:00 2001 From: "Win8.1VMUser" <78744628+Win81VMUser@users.noreply.github.com> Date: Sun, 27 Jul 2025 18:30:27 +0200 Subject: [PATCH] Update index.ts --- plugins/nsfwbypass/src/index.ts | 98 +++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/plugins/nsfwbypass/src/index.ts b/plugins/nsfwbypass/src/index.ts index 80a17dc..a7524de 100644 --- a/plugins/nsfwbypass/src/index.ts +++ b/plugins/nsfwbypass/src/index.ts @@ -2,6 +2,8 @@ import { findByStoreName, findByProps, findByName } from "@vendetta/metro"; import { after, instead } from "@vendetta/patcher"; import { showConfirmationAlert } from "@vendetta/ui/alerts"; import { React } from "@vendetta/metro/common"; +import { storage } from "@vendetta/plugin"; +import { Settings } from "./Settings"; const { Text } = findByProps("Button", "Text", "View"); @@ -11,6 +13,7 @@ const { getChannel } = findByProps("getChannel") || findByName("getChannel", fal let patches = []; +// Helper function to check if a channel is NSFW function isNSFWChannel(channelId) { if (typeof channelId === "string") { const channel = getChannel(channelId); @@ -19,6 +22,7 @@ function isNSFWChannel(channelId) { return channelId?.nsfw === true; } +// Warning content component function NSFWWarningContent() { return React.createElement( Text, @@ -29,48 +33,60 @@ function NSFWWarningContent() { export default { onLoad: () => { - patches.push(instead("handleNSFWGuildInvite", NSFWStuff, () => false)); - patches.push(instead("isNSFWInvite", NSFWStuff, () => false)); - patches.push(instead("shouldNSFWGateGuild", NSFWStuff, () => false)); - - // User store patch to modify nsfwAllowed property - patches.push(after("getCurrentUser", UserStore, (_, user) => { - if (user?.hasOwnProperty("nsfwAllowed")) { - user.nsfwAllowed = true; - } - if (user?.hasOwnProperty("ageVerificationStatus")) { - user.ageVerificationStatus = 3; // VERIFIED_ADULT - } - return user; - })); + // Initialize default settings + storage.ageBypass ??= false; // Default to false for password-protected feature + storage.nsfwBypass ??= true; + storage.showWarningPopup ??= true; - // Add NSFW channel warning - const transitionToGuild = findByProps("transitionToGuild"); - if (transitionToGuild) { - for (const key of Object.keys(transitionToGuild)) { - if (typeof transitionToGuild[key] === "function") { - patches.push( - instead(key, transitionToGuild, (args, orig) => { - if (typeof args[0] === "string") { - const pathMatch = args[0].match(/(\d+)$/); - if (pathMatch?.[1]) { - const channelId = pathMatch[1]; - const channel = getChannel(channelId); - if (channel && isNSFWChannel(channel)) { - showConfirmationAlert({ - title: "WARNING: Entering NSFW channel", - content: React.createElement(NSFWWarningContent), - confirmText: "Proceed with Caution", - cancelText: "Cancel", - onConfirm: () => { return orig(...args); }, - }); - return {}; + // NSFW bypass patches - only if enabled + if (storage.nsfwBypass) { + patches.push(instead("handleNSFWGuildInvite", NSFWStuff, () => false)); + patches.push(instead("isNSFWInvite", NSFWStuff, () => false)); + patches.push(instead("shouldNSFWGateGuild", NSFWStuff, () => false)); + } + + // Age verification bypass - only if enabled + if (storage.ageBypass) { + patches.push(after("getCurrentUser", UserStore, (_, user) => { + if (user?.hasOwnProperty("nsfwAllowed")) { + user.nsfwAllowed = true; + } + if (user?.hasOwnProperty("ageVerificationStatus")) { + user.ageVerificationStatus = 3; // VERIFIED_ADULT + } + return user; + })); + } + + // NSFW channel warning - only if enabled + if (storage.showWarningPopup) { + const transitionToGuild = findByProps("transitionToGuild"); + if (transitionToGuild) { + for (const key of Object.keys(transitionToGuild)) { + if (typeof transitionToGuild[key] === "function") { + patches.push( + instead(key, transitionToGuild, (args, orig) => { + if (typeof args[0] === "string") { + const pathMatch = args[0].match(/(\d+)$/); + if (pathMatch?.[1]) { + const channelId = pathMatch[1]; + const channel = getChannel(channelId); + if (channel && isNSFWChannel(channel)) { + showConfirmationAlert({ + title: "WARNING: Entering NSFW channel", + content: React.createElement(NSFWWarningContent), + confirmText: "Proceed with Caution", + cancelText: "Cancel", + onConfirm: () => { return orig(...args); }, + }); + return {}; + } } } - } - return orig(...args); - }) - ); + return orig(...args); + }) + ); + } } } } @@ -81,5 +97,7 @@ export default { unpatch(); } patches = []; - } + }, + + settings: Settings };