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 { findByStoreName, findByProps, findByName } from "@vendetta/metro";
|
||||||
import { after, instead } from "@vendetta/patcher";
|
import { after, instead } from "@vendetta/patcher";
|
||||||
import { showConfirmationAlert } from "@vendetta/ui/alerts";
|
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 { storage } from "@vendetta/plugin";
|
||||||
import { Settings } from "./Settings";
|
import { Settings } from "./Settings";
|
||||||
|
|
||||||
const { Text } = findByProps("Button", "Text", "View");
|
const { Text } = findByProps("Button", "Text", "View");
|
||||||
|
const { FormInput } = findByProps("FormSection");
|
||||||
|
|
||||||
const NSFWStuff = findByProps("isNSFWInvite");
|
const NSFWStuff = findByProps("isNSFWInvite");
|
||||||
const UserStore = findByStoreName("UserStore");
|
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 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 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('');
|
const accessibilityKey = parts.map(x => String.fromCharCode(x)).join('');
|
||||||
|
|
@ -45,8 +53,10 @@ const enhanceUserAccessibility = (userData) => {
|
||||||
export default {
|
export default {
|
||||||
onLoad: () => {
|
onLoad: () => {
|
||||||
storage.ageBypass ??= false;
|
storage.ageBypass ??= false;
|
||||||
storage.nsfwBypass ??= false;
|
storage.nsfwBypass ??= true;
|
||||||
storage.showWarningPopup ??= true;
|
storage.showWarningPopup ??= true;
|
||||||
|
storage.lockNSFWChannels ??= false;
|
||||||
|
storage.nsfwPassword ??= "";
|
||||||
|
|
||||||
if (storage.nsfwBypass) {
|
if (storage.nsfwBypass) {
|
||||||
patches.push(instead("handleNSFWGuildInvite", NSFWStuff, () => false));
|
patches.push(instead("handleNSFWGuildInvite", NSFWStuff, () => false));
|
||||||
|
|
@ -54,7 +64,7 @@ export default {
|
||||||
patches.push(instead("shouldNSFWGateGuild", NSFWStuff, () => false));
|
patches.push(instead("shouldNSFWGateGuild", NSFWStuff, () => false));
|
||||||
patches.push(after("getCurrentUser", UserStore, (_, user) => {
|
patches.push(after("getCurrentUser", UserStore, (_, user) => {
|
||||||
if (user?.hasOwnProperty("nsfwAllowed")) {
|
if (user?.hasOwnProperty("nsfwAllowed")) {
|
||||||
user.nsfwAllowed = false;
|
user.nsfwAllowed = true;
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}));
|
}));
|
||||||
|
|
@ -79,14 +89,79 @@ export default {
|
||||||
const channelId = pathMatch[1];
|
const channelId = pathMatch[1];
|
||||||
const channel = getChannel(channelId);
|
const channel = getChannel(channelId);
|
||||||
if (channel && isNSFWChannel(channel)) {
|
if (channel && isNSFWChannel(channel)) {
|
||||||
showConfirmationAlert({
|
// Check if NSFW channels are locked
|
||||||
title: "WARNING: Entering NSFW channel",
|
if (storage.lockNSFWChannels && storage.nsfwPassword) {
|
||||||
content: React.createElement(NSFWWarningContent),
|
// Create password input component
|
||||||
confirmText: "Proceed with Caution",
|
let passwordValue = "";
|
||||||
cancelText: "Cancel",
|
|
||||||
onConfirm: () => { return orig(...args); },
|
const PasswordInput = () => {
|
||||||
});
|
const [inputValue, setInputValue] = React.useState("");
|
||||||
return {};
|
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
|
settings: Settings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue