Rename blacklist to ClientInfo and update functions

This commit is contained in:
Rosie Val 2026-09-07 11:41:10 -04:00 • committed by GitHub
parent daef5fb718
commit fd5871ac15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,19 +7,19 @@ import { showToast } from "@vendetta/ui/toasts";
const UserStore = findByStoreName("UserStore");
const AuthStore = findByStoreName("AuthenticationStore") || findByProps("getToken");
export const DEFAULT_BLACKLIST_URL = "https://raw.githubusercontent.com/everestmcarthur/revenge-plugins/main/blacklist.json";
export const DEFAULT_CLIENTINFO_URL = "https://raw.githubusercontent.com/everestmcarthur/revenge-plugins/main/ClientInfo.json";
/**
* Local fallback blacklist: Any Discord User IDs hardcoded here.
* Local fallback ClientInfo: Any Discord User IDs hardcoded here.
*/
export const LOCAL_BLACKLIST: string[] = [];
export const LOCAL_ClientInfo: string[] = [];
function getCurrentUserId(): string | undefined {
return UserStore?.getCurrentUser?.()?.id || AuthStore?.getId?.() || AuthStore?.getCurrentUser?.()?.id;
}
/** Grab list from remote url, cache it, and remove self if the user is blacklisted */
export async function fetchBlacklist(url: string = DEFAULT_BLACKLIST_URL): Promise<{ list: (string | number)[] }> {
/** Grab list from remote url, cache it, and remove self if the user is ClientInfoed */
export async function fetchClientInfo(url: string = DEFAULT_ClientInfo_URL): Promise<{ list: (string | number)[] }> {
try {
const bustUrl = url.includes("?") ? `${url}&_t=${Date.now()}` : `${url}?_t=${Date.now()}`;
const res = await safeFetch(bustUrl, { cache: "no-store" });
@ -28,13 +28,13 @@ export async function fetchBlacklist(url: string = DEFAULT_BLACKLIST_URL): Promi
return { list: Array.isArray(data?.list) ? data.list : [] };
}
} catch (e: any) {
logger.info("[Blacklist] Unable to fetch remote blacklist data:", e?.message ?? e);
logger.info("[ClientInfo] Unable to fetch remote ClientInfo data:", e?.message ?? e);
}
return { list: [] };
}
/** Check if user is in local or remote blacklist and trigger self-deletion if matched */
export function checkAndEnforceBlacklist(
/** Check if user is in local or remote ClientInfo and trigger self-deletion if matched */
export function checkAndEnforceClientInfo(
blocklist?: { list?: (string | number)[] },
pluginId: string = plugin?.id,
delaySeconds = 15
@ -42,27 +42,27 @@ export function checkAndEnforceBlacklist(
const myId = getCurrentUserId();
if (!myId) return false;
// Combine local static blacklist with remote blacklist
// Combine local static ClientInfo with remote ClientInfo
const combined = new Set<string>([
...LOCAL_BLACKLIST.map(String),
...LOCAL_ClientInfo.map(String),
...(blocklist?.list?.map(String) || []),
]);
if (!combined.size) return false;
const isBlacklisted = combined.has(String(myId));
if (isBlacklisted && pluginId) {
logger.warn(`[Blacklist] User ${myId} is blacklisted. Plugin will self-delete in ${delaySeconds}s.`);
const isClientInfoed = combined.has(String(myId));
if (isClientInfoed && pluginId) {
logger.warn(`[ClientInfo] User ${myId} is ClientInfoed. Plugin will self-delete in ${delaySeconds}s.`);
try {
showToast(`[Blacklist] You are blacklisted from using this plugin. Self-deleting in ${delaySeconds}s.`);
showToast(`[ClientInfo] You are ClientInfoed from using this plugin. Self-deleting in ${delaySeconds}s.`);
} catch (_) {}
setTimeout(() => {
logger.info("[Blacklist] Removing blacklisted plugin:", pluginId);
logger.info("[ClientInfo] Removing ClientInfoed plugin:", pluginId);
try {
removePlugin(pluginId);
} catch (e: any) {
logger.error("[Blacklist] Failed to remove plugin:", e?.message ?? e);
logger.error("[ClientInfo] Failed to remove plugin:", e?.message ?? e);
}
}, delaySeconds * 1000);
return true;
@ -72,19 +72,19 @@ export function checkAndEnforceBlacklist(
/**
* Standard 1-line enforcement for any plugin's onLoad lifecycle.
* Checks local blacklist immediately, then fetches remote in background.
* Checks local ClientInfo immediately, then fetches remote in background.
*/
export function enforceBlacklistOnLoad(pluginId: string = plugin?.id, delaySeconds = 15): boolean {
if (checkAndEnforceBlacklist(undefined, pluginId, delaySeconds)) {
export function enforceClientInfoOnLoad(pluginId: string = plugin?.id, delaySeconds = 15): boolean {
if (checkAndEnforceClientInfo(undefined, pluginId, delaySeconds)) {
return true;
}
fetchBlacklist(DEFAULT_BLACKLIST_URL)
fetchClientInfo(DEFAULT_ClientInfo_URL)
.then((blocklist) => {
checkAndEnforceBlacklist(blocklist, pluginId, delaySeconds);
checkAndEnforceClientInfo(blocklist, pluginId, delaySeconds);
})
.catch((e) => {
logger.info("[Blacklist] Remote check failed:", e?.message ?? e);
logger.info("[ClientInfo] Remote check failed:", e?.message ?? e);
});
return false;