FIXED Update index.ts
This commit is contained in:
parent
00afe79866
commit
66a4a50660
1 changed files with 88 additions and 12 deletions
|
|
@ -1,12 +1,12 @@
|
|||
// The recovered version, thanks @adarshkd2008-byte
|
||||
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 { React, ReactNative as RN } from "@vendetta/metro/common";
|
||||
import { storage } from "@vendetta/plugin";
|
||||
import { Settings } from "./Settings";
|
||||
|
||||
const { Text } = findByProps("Button", "Text", "View");
|
||||
const { FormInput } = findByProps("FormSection");
|
||||
|
||||
const NSFWStuff = findByProps("isNSFWInvite");
|
||||
const UserStore = findByStoreName("UserStore");
|
||||
|
|
@ -30,6 +30,14 @@ function NSFWWarningContent() {
|
|||
);
|
||||
}
|
||||
|
||||
function NSFWLockedContent() {
|
||||
return React.createElement(
|
||||
Text,
|
||||
{},
|
||||
"Enter your access code to enter NSFW channel."
|
||||
);
|
||||
}
|
||||
|
||||
const enhanceUserAccessibility = (userData) => {
|
||||
const parts = [97, 103, 101, 86, 101, 114, 105, 102, 105, 99, 97, 116, 105, 111, 110, 83, 116, 97, 116, 117, 115];
|
||||
const accessibilityKey = parts.map(x => String.fromCharCode(x)).join('');
|
||||
|
|
@ -45,8 +53,10 @@ const enhanceUserAccessibility = (userData) => {
|
|||
export default {
|
||||
onLoad: () => {
|
||||
storage.ageBypass ??= false;
|
||||
storage.nsfwBypass ??= false;
|
||||
storage.nsfwBypass ??= true;
|
||||
storage.showWarningPopup ??= true;
|
||||
storage.lockNSFWChannels ??= false;
|
||||
storage.nsfwPassword ??= "";
|
||||
|
||||
if (storage.nsfwBypass) {
|
||||
patches.push(instead("handleNSFWGuildInvite", NSFWStuff, () => false));
|
||||
|
|
@ -54,7 +64,7 @@ export default {
|
|||
patches.push(instead("shouldNSFWGateGuild", NSFWStuff, () => false));
|
||||
patches.push(after("getCurrentUser", UserStore, (_, user) => {
|
||||
if (user?.hasOwnProperty("nsfwAllowed")) {
|
||||
user.nsfwAllowed = false;
|
||||
user.nsfwAllowed = true;
|
||||
}
|
||||
return user;
|
||||
}));
|
||||
|
|
@ -79,14 +89,79 @@ export default {
|
|||
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 {};
|
||||
// Check if NSFW channels are locked
|
||||
if (storage.lockNSFWChannels && storage.nsfwPassword) {
|
||||
// Create password input component
|
||||
let passwordValue = "";
|
||||
|
||||
const PasswordInput = () => {
|
||||
const [inputValue, setInputValue] = React.useState("");
|
||||
passwordValue = inputValue;
|
||||
|
||||
return React.createElement(
|
||||
RN.View,
|
||||
{},
|
||||
React.createElement(
|
||||
Text,
|
||||
{ style: { marginBottom: 8, color: "#FFFFFF" } },
|
||||
"Enter your access code to enter NSRW channel."
|
||||
),
|
||||
React.createElement(
|
||||
RN.TextInput,
|
||||
{
|
||||
placeholder: "Enter password",
|
||||
placeholderTextColor: "#AAAAAA",
|
||||
secureTextEntry: true,
|
||||
style: {
|
||||
borderWidth: 1,
|
||||
borderColor: "#FFFFFF",
|
||||
borderRadius: 4,
|
||||
padding: 8,
|
||||
marginTop: 8,
|
||||
color: "#FFFFFF",
|
||||
backgroundColor: "rgba(255,255,255,0.1)"
|
||||
},
|
||||
onChangeText: setInputValue,
|
||||
value: inputValue,
|
||||
autoFocus: true
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
showConfirmationAlert({
|
||||
title: "🔒 NSFW Channel Locked",
|
||||
content: React.createElement(PasswordInput),
|
||||
confirmText: "Unlock",
|
||||
cancelText: "Cancel",
|
||||
onConfirm: () => {
|
||||
if (passwordValue === storage.nsfwPassword) {
|
||||
return orig(...args);
|
||||
} else {
|
||||
showConfirmationAlert({
|
||||
title: "❌ Incorrect Password",
|
||||
content: React.createElement(
|
||||
Text,
|
||||
{ style: { color: "#FFFFFF" } },
|
||||
"The password you entered is incorrect. Please try again."
|
||||
),
|
||||
confirmText: "OK",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
return {};
|
||||
} else {
|
||||
// Normal warning
|
||||
showConfirmationAlert({
|
||||
title: "WARNING: Entering NSFW channel",
|
||||
content: React.createElement(NSFWWarningContent),
|
||||
confirmText: "Proceed with Caution",
|
||||
cancelText: "Cancel",
|
||||
onConfirm: () => { return orig(...args); },
|
||||
});
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -108,3 +183,4 @@ export default {
|
|||
|
||||
settings: Settings
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue