From 715e6f9bc4e184e943b4aac5f7dae4b4f207833c Mon Sep 17 00:00:00 2001 From: Beef Date: Sat, 7 Jan 2023 03:13:16 +0000 Subject: [PATCH] [Cleanup] Small tidying --- src/index.ts | 2 +- src/lib/metro/common.ts | 5 +++++ src/lib/utils/copyText.ts | 4 +--- src/ui/assets.ts | 10 ++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7461c97..0c1562b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,7 +50,7 @@ async function init() { patchLogHook(); } catch (e: Error | any) { erroredOnLoad = true; - alert(`Vendetta failed to initialize...\n${e.stack || e.toString()}`); + alert(`Vendetta failed to initialize... ${e.stack || e.toString()}`); } if (!erroredOnLoad) logger.log("Vendetta is ready!"); diff --git a/src/lib/metro/common.ts b/src/lib/metro/common.ts index 82f2889..c0d3bb9 100644 --- a/src/lib/metro/common.ts +++ b/src/lib/metro/common.ts @@ -7,6 +7,11 @@ export const i18n = findByProps("Messages"); export const url = findByProps("openURL"); export const toasts = find(m => m.open && m.close && !m.startDrag && !m.init && !m.openReplay && !m.setAlwaysOnTop); export const stylesheet = findByProps("createThemedStyleSheet"); +export const clipboard = findByProps("setString", "getString"); +export const assets = findByProps("registerAsset"); +export const navigation = findByProps("pushLazy"); +export const navigationStack = findByProps("createStackNavigator"); +export const NavigationNative = findByProps("NavigationContainer"); // React export const React = findByProps("createElement") as typeof import("react"); diff --git a/src/lib/utils/copyText.ts b/src/lib/utils/copyText.ts index 1dc3d79..dd3ec15 100644 --- a/src/lib/utils/copyText.ts +++ b/src/lib/utils/copyText.ts @@ -1,6 +1,4 @@ -import { findByProps } from "@metro/filters"; - -const clipboard = findByProps("setString", "getString"); +import { clipboard } from "@metro/common"; export default function copyText(content: string) { try { diff --git a/src/ui/assets.ts b/src/ui/assets.ts index 908e93c..88ea00a 100644 --- a/src/ui/assets.ts +++ b/src/ui/assets.ts @@ -1,20 +1,18 @@ import { Asset, Assets } from "@types"; import { after } from "@lib/patcher"; -import { findByProps } from "@metro/filters"; - -const assetsModule = findByProps("registerAsset"); +import { assets } from "@metro/common"; export const all: Assets = {}; export default function patchAssets() { try { - after("registerAsset", assetsModule, (args: Asset[], id: number) => { + after("registerAsset", assets, (args: Asset[], id: number) => { const asset = args[0]; all[asset.name] = { ...asset, id: id }; }); for (let id = 1; ; id++) { - const asset = assetsModule.getAssetByID(id); + const asset = assets.getAssetByID(id); if (!asset) break; if (all[asset.name]) continue; all[asset.name] = { ...asset, id: id }; @@ -24,5 +22,5 @@ export default function patchAssets() { export const find = (filter: (a: any) => void): Asset | null | undefined => Object.values(all).find(filter); export const getAssetByName = (name: string): Asset => all[name]; -export const getAssetByID = (id: number): Asset => assetsModule.getAssetByID(id); +export const getAssetByID = (id: number): Asset => assets.getAssetByID(id); export const getAssetIDByName = (name: string) => all[name]?.id; \ No newline at end of file