From 83b3b1f16b65eda408dd0a5984543bd9e6c15f3d Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 17 Nov 2022 13:49:51 +0100 Subject: fix settings debug info on web --- src/plugins/settings.tsx | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/settings.tsx b/src/plugins/settings.tsx index b3b49b6..ec42956 100644 --- a/src/plugins/settings.tsx +++ b/src/plugins/settings.tsx @@ -56,17 +56,36 @@ export default definePlugin({ } }], + get electronVersion() { + return VencordNative.getVersions().electron || window.armcord?.electron || null; + }, + + get chromiumVersion() { + try { + return VencordNative.getVersions().chrome + // @ts-ignore Typescript will add userAgentData IMMEDIATELY + || navigator.userAgentData?.brands?.find(b => b.brand === "Chromium" || b.brand === "Google Chrome")?.version + || null; + } catch { // inb4 some stupid browser throws unsupported error for navigator.userAgentData, it's only in chromium + return null; + } + }, + + get additionalInfo() { + if (IS_DEV) return " (Dev)"; + if (IS_WEB) return " (Web)"; + if (IS_STANDALONE) return " (Standalone)"; + return ""; + }, + makeInfoElements(Component: React.ComponentType, props: React.PropsWithChildren) { - const additionalInfo = IS_WEB - ? " (Web)" - : IS_STANDALONE - ? " (Standalone)" - : ""; + const { electronVersion, chromiumVersion, additionalInfo } = this; + return ( <> Vencord {gitHash}{additionalInfo} - Electron {VencordNative.getVersions().electron} - Chromium {VencordNative.getVersions().chrome} + {electronVersion && Electron {electronVersion}} + {chromiumVersion && Chromium {chromiumVersion}} ); } -- cgit