From 585a1035c00e0061a6648cc0730b3d0bb8855431 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:31:12 +0000 Subject: [PATCH 1/3] its shiggy season --- index.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 9d34bcf..d2b7a27 100644 --- a/index.ts +++ b/index.ts @@ -101,10 +101,34 @@ function humanFileSize(bytes, si = false, dp = 1) { return bytes.toFixed(dp) + " " + units[u]; } +let BUILD_NUMBER; +let VERSION_HASH; + export default definePlugin({ name: "venfetch", description: "neofetch for vencord", authors: [Devs.nin0dev], + patches: [ + { + find: /.log\("[BUILD INFO]/, + replacement: [ + { + match: /Build Number: "\).concat\(("\d+")/, + replace: "Build Number: \").concat($self.setBuildNumber($1)" + }, + { + match: /Version Hash: \"\).concat\(("\w+")/, + replace: "Version Hash: \").concat($self.setVersionHash($1)" + } + ] + } + ], + setBuildNumber(buildNumber) { + return BUILD_NUMBER = buildNumber; + }, + setVersionHash(versionHash) { + return VERSION_HASH = versionHash; + }, commands: [ { name: "venfetch", @@ -115,8 +139,10 @@ export default definePlugin({ const info: Record = { version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`, client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`, + // TODO: fix this + // build: `${BUILD_NUMBER ?? "Unknown"} (${VERSION_HASH?.slice(0, 7) ?? 'unknown'})`, // @ts-ignore - platform: navigator.userAgentData?.platform ?? navigator.platform, + platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, plugins: getEnabledPlugins(), uptime: `${~~((Date.now() - uptime) / 1000)}s`, // TODO: pr to vencord real and add to vencordnative @@ -124,7 +150,7 @@ export default definePlugin({ _: null, donor: getDonorStatus() ? "yes" : "no", - contributor: getContribStatus() ? "yes" : null, + contributor: getContribStatus() ? "yes" : "no", __: null, From 59c84ebb5d274b679e79915f583422fe736379b4 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:32:44 +0000 Subject: [PATCH 2/3] fix bug --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index d2b7a27..2bec7ed 100644 --- a/index.ts +++ b/index.ts @@ -67,7 +67,7 @@ function getEnabledPlugins() { let userpluginsCount = 0; Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { - if (value.started) if (PluginMeta[value.name].userPlugin) userpluginsCount++; else counter++; + if (value.started) if (PluginMeta[value.name]?.userPlugin) userpluginsCount++; else counter++; }); return `${counter} (official)` + (userpluginsCount ? `, ${userpluginsCount} (userplugins)` : ""); From 5c867c19f986a21937f3607eeed412b06eedf5b2 Mon Sep 17 00:00:00 2001 From: splatter Date: Sun, 27 Oct 2024 15:46:08 +0000 Subject: [PATCH 3/3] add build number --- index.ts | 59 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/index.ts b/index.ts index 2bec7ed..e7d32fd 100644 --- a/index.ts +++ b/index.ts @@ -14,6 +14,7 @@ import { GuildMemberStore, UserStore } from "@webpack/common"; import { PluginMeta } from "~plugins"; import SettingsPlugin from "../../plugins/_core/settings"; +import { findByCodeLazy } from "../../webpack/webpack.js"; const clientVersion = () => { const version = IS_DISCORD_DESKTOP ? DiscordNative.app.getVersion() : IS_VESKTOP ? VesktopNative.app.getVersion() : null; @@ -63,14 +64,28 @@ VV VV // ```; function getEnabledPlugins() { - let counter = 0; - let userpluginsCount = 0; + const counters = { + official: { + enabled: 0, + total: 0 + }, + user: { + enabled: 0, + total: 0 + } + } Object.entries(Vencord.Plugins.plugins).forEach(([key, value]) => { - if (value.started) if (PluginMeta[value.name]?.userPlugin) userpluginsCount++; else counter++; + if (PluginMeta[value.name]?.userPlugin) { + if (value.started) counters.user.enabled++; + counters.user.total++; + } else { + if (value.started) counters.official.enabled++; + counters.official.total++; + } }); - return `${counter} (official)` + (userpluginsCount ? `, ${userpluginsCount} (userplugins)` : ""); + return `${counters.official.enabled} / ${counters.official.total} (official)` + (counters.user.total ? `, ${counters.user.enabled} / ${counters.user.total} (userplugins)` : ""); } function getDonorStatus() { return GuildMemberStore.getMember("1015060230222131221", UserStore.getCurrentUser().id).roles.includes("1042507929485586532"); @@ -104,31 +119,13 @@ function humanFileSize(bytes, si = false, dp = 1) { let BUILD_NUMBER; let VERSION_HASH; + +const getVersions = findByCodeLazy("logsUploaded:new Date().toISOString(),") + export default definePlugin({ name: "venfetch", description: "neofetch for vencord", authors: [Devs.nin0dev], - patches: [ - { - find: /.log\("[BUILD INFO]/, - replacement: [ - { - match: /Build Number: "\).concat\(("\d+")/, - replace: "Build Number: \").concat($self.setBuildNumber($1)" - }, - { - match: /Version Hash: \"\).concat\(("\w+")/, - replace: "Version Hash: \").concat($self.setVersionHash($1)" - } - ] - } - ], - setBuildNumber(buildNumber) { - return BUILD_NUMBER = buildNumber; - }, - setVersionHash(versionHash) { - return VERSION_HASH = versionHash; - }, commands: [ { name: "venfetch", @@ -136,23 +133,27 @@ export default definePlugin({ inputType: ApplicationCommandInputType.BUILT_IN, execute: (args: Argument[], ctx: CommandContext) => { const { username } = UserStore.getCurrentUser(); + const versions = getVersions(); const info: Record = { version: `${VERSION} ~ ${gitHash}${SettingsPlugin.additionalInfo} - ${Intl.DateTimeFormat(navigator.language, { dateStyle: "medium" }).format(BUILD_TIMESTAMP)}`, client: `${t(window.GLOBAL_ENV.RELEASE_CHANNEL)} ~ ${clientVersion()}`, - // TODO: fix this - // build: `${BUILD_NUMBER ?? "Unknown"} (${VERSION_HASH?.slice(0, 7) ?? 'unknown'})`, + 'Build Number': `${versions.buildNumber} ~ Hash: ${ versions.versionHash?.slice(0, 7) ?? 'unknown' }`, + + _: null, + // @ts-ignore platform: navigator.userAgentData?.platform ? `${navigator.userAgentData?.platform} (${navigator.platform})` : navigator.platform, plugins: getEnabledPlugins(), uptime: `${~~((Date.now() - uptime) / 1000)}s`, // TODO: pr to vencord real and add to vencordnative // memory: `${humanFileSize(VencordNative.memoryUsage().heapUsed)} / ${humanFileSize(VencordNative.memoryUsage().heapTotal)}`, - _: null, + + __: null, donor: getDonorStatus() ? "yes" : "no", contributor: getContribStatus() ? "yes" : "no", - __: null, + ___: null, __COLOR_TEST__: "███████████████████████████"