diff --git a/README.md b/README.md index da3cefc9..f9d0ea10 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch ### Extra included plugins
-151 additional plugins +150 additional plugins ### All Platforms - AllCallTimers by MaxHerbold & D3SOX @@ -151,7 +151,6 @@ You can join our [discord server](https://discord.gg/5Xh2W87egW) for commits, ch - ViewRawVariant (ViewRaw2) by Kyuuhachi - VoiceChatUtilities by D3SOX - VoiceJoinMessages by Sqaaakoi & maintained by thororen -- WebpackTarball by Kyuuhachi - WhitelistedEmojis by Creations - WhosWatching by fres - WigglyText by nexpid diff --git a/src/debug/reporterData.ts b/src/debug/reporterData.ts index 1bce68f6..9e6dde23 100644 --- a/src/debug/reporterData.ts +++ b/src/debug/reporterData.ts @@ -11,7 +11,7 @@ import { Patch } from "@utils/types"; import { TypeWebpackSearchHistory } from "@webpack"; interface EvaledPatch extends Patch { - id: number | string; + id: PropertyKey; } interface ErroredPatch extends EvaledPatch { oldModule: string, diff --git a/src/equicordplugins/webpackTarball/index.tsx b/src/equicordplugins/webpackTarball/index.tsx deleted file mode 100644 index 68f0f400..00000000 --- a/src/equicordplugins/webpackTarball/index.tsx +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { definePluginSettings } from "@api/Settings"; -import { Devs, WEBPACK_CHUNK } from "@utils/constants"; -import { makeLazy } from "@utils/lazy"; -import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; -import definePlugin, { OptionType } from "@utils/types"; -import { findByProps, wreq } from "@webpack"; -import { Button, Flex, Forms, Switch, Text, Timestamp, useState } from "@webpack/common"; - -import TarFile from "./tar"; -import * as Webpack from "./webpack"; - -export const settings = definePluginSettings({ - patched: { - type: OptionType.BOOLEAN, - default: true, - description: "Include patched modules", - restartNeeded: true, - }, -}); - -export default definePlugin({ - name: "WebpackTarball", - description: "Converts Discord's webpack sources into a tarball.", - authors: [Devs.Kyuuhachi], - settings, - - toolboxActions: { - "Webpack Tarball"() { - const key = openModal(props => ( - closeModal(key)} - /> - )); - } - }, -}); - -export const getBuildNumber = makeLazy(() => { - try { - const metrics = findByProps("_getMetricWithDefaults")._flush.toString(); - const [, builtAt, buildNumber] = metrics.match(/\{built_at:"(\d+)",build_number:"(\d+)"\}/); - return { buildNumber, builtAt: new Date(Number(builtAt)) }; - } catch (e) { - console.error("failed to get build number:", e); - return { buildNumber: "unknown", builtAt: new Date() }; - } -}); - -async function saveTar(patched: boolean) { - const tar = new TarFile(); - const { buildNumber, builtAt } = getBuildNumber(); - const mtime = (builtAt.getTime() / 1000) | 0; - - const root = patched ? `vencord-${buildNumber}` : `discord-${buildNumber}`; - - for (const [id, module] of Object.entries(wreq.m)) { - const patchedSrc = Function.toString.call(module); - const originalSrc = module.toString(); - if (patched && patchedSrc !== originalSrc) - tar.addTextFile( - `${root}/${id}.v.js`, - `webpack[${JSON.stringify(id)}] = ${patchedSrc}\n`, - { mtime }, - ); - tar.addTextFile( - `${root}/${id}.js`, - `webpack[${JSON.stringify(id)}] = ${originalSrc}\n`, - { mtime }, - ); - } - tar.save(`${root}.tar`); -} - -function TarModal({ modalProps, close }: { modalProps: ModalProps; close(): void; }) { - const { buildNumber, builtAt } = getBuildNumber(); - const [, rerender] = useState({}); - const [isLoading, setLoading] = useState(false); - const paths = Webpack.getChunkPaths(wreq); - const status = Object.entries(Webpack.getLoadedChunks(wreq)) - .filter(([k]) => wreq.o(paths, k)) - .map(([, v]) => v); - const loading = status.length; - const loaded = status.filter(v => v === 0 || v === undefined).length; - const errored = status.filter(v => v === undefined).length; - const all = Object.keys(paths).length; - const { patched } = settings.use(["patched"]); - return ( - - - - Webpack Tarball - - - - {"Build number "} - {buildNumber} - - - - - - -
- - Lazy chunks - - - - {loaded}/{all} - {errored ? ` (${errored} errors)` : null} - - - -
- - settings.store.patched = v} - hideBorder - > - {settings.def.patched.description} - -
- - - - -
- ); -} diff --git a/src/equicordplugins/webpackTarball/tar.ts b/src/equicordplugins/webpackTarball/tar.ts deleted file mode 100644 index d23ec2a7..00000000 --- a/src/equicordplugins/webpackTarball/tar.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -export type Metadata = { mtime?: number; }; -export default class TarFile { - buffers: ArrayBuffer[]; - - constructor() { - this.buffers = []; - } - - addTextFile(name: string, text: string, metadata: Metadata = {}) { - this.addFile(name, new TextEncoder().encode(text), metadata); - } - - addFile(name: string, data: Uint8Array, { mtime = 0 }: Metadata = {}) { - this.buffers.push(this.header([ - [100, name.toString()], // name - [8, 0o644], // mode - [8, 0o1000], // uid - [8, 0o1000], // gid - [12, data.length], // size - [12, mtime], // mtime - [8, null], // checksum - [1, "0"], // type - [100, ""], // name of linked file (??) - [255, ""], // padding - ])); - this.buffers.push(data.buffer as ArrayBuffer); - this.buffers.push(new ArrayBuffer(-data.length & 0x1FF)); - } - - header(fields: [number, number | string | null][]) { - const buffer = new ArrayBuffer(512); - const u1 = new Uint8Array(buffer); - let checksum = 0; - let checksumPos: number = null!; - - let pos = 0; - for (const [size, val] of fields) { - let string: string; - if (val === null) { - checksumPos = pos; - string = " ".repeat(size); - } else if (typeof val === "string") { - string = val; - } else if (typeof val === "number") { - string = val.toString(8).padStart(size - 1, "0"); - } else { - throw new Error("invalid value", val); - } - if (string.length > size) throw new Error(`${string} is longer than ${size} characters`); - Array.from(string).forEach((c, i) => checksum += u1[pos + i] = c.charCodeAt(0)); - pos += size; - } - Array.from("\0".repeat(8)).forEach((c, i) => u1[checksumPos + i] = c.charCodeAt(0)); - Array.from(checksum.toString(8).padStart(7, "0")).forEach((c, i) => u1[checksumPos + i] = c.charCodeAt(0)); - return buffer; - } - - save(filename: string) { - const a = document.createElement("a"); - a.href = URL.createObjectURL(new Blob(this.buffers, { "type": "application/x-tar" })); - a.download = filename; - a.style.display = "none"; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(a.href); - } -} diff --git a/src/equicordplugins/webpackTarball/webpack.ts b/src/equicordplugins/webpackTarball/webpack.ts deleted file mode 100644 index da0bf4b6..00000000 --- a/src/equicordplugins/webpackTarball/webpack.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import type { WebpackInstance } from "discord-types/other"; - -export async function protectWebpack(webpack: any[], body: () => Promise): Promise { - const prev_m = Object.getOwnPropertyDescriptor(Function.prototype, "m")!; - Object.defineProperty(Function.prototype, "m", { - get() { throw "get require.m"; }, - set() { throw "set require.m"; }, - enumerable: true, - configurable: true, - }); - - try { - return await body(); - } finally { - Object.defineProperty(Function.prototype, "m", prev_m); - } -} - -export function getLoadedChunks(wreq: WebpackInstance): { [chunkId: string | symbol]: 0 | undefined; } { - const { o } = wreq; - try { - wreq.o = (a: any) => { throw a; }; - wreq.f.j(); - } catch (e: any) { - return e; - } finally { - wreq.o = o; - } - throw new Error("getLoadedChunks failed"); -} - -export function getChunkPaths(wreq: WebpackInstance): { [chunkId: string]: string; } { - const sym = Symbol("getChunkPaths"); - try { - Object.defineProperty(Object.prototype, sym, { - get() { throw this; }, - set() { }, - configurable: true, - }); - wreq.u(sym); - } catch (e: any) { - return e; - } finally { - // @ts-ignore - delete Object.prototype[sym]; - } - throw new Error("getChunkPaths failed"); -} - -export async function forceLoadAll(wreq: WebpackInstance, on_chunk: (id: string) => void = () => { }) { - const chunks = getChunkPaths(wreq); - const loaded = getLoadedChunks(wreq); - const ids = Object.keys(chunks).filter(id => loaded[id] !== 0); - await Promise.all(ids.map(async id => { - try { - await wreq.e(id as any); - } catch { } - on_chunk(id); - })); -} diff --git a/src/plugins/_core/settings.tsx b/src/plugins/_core/settings.tsx index fcabcc1c..bbd18112 100644 --- a/src/plugins/_core/settings.tsx +++ b/src/plugins/_core/settings.tsx @@ -229,6 +229,7 @@ export default definePlugin({ if (IS_DEV) return " (Dev)"; if (IS_WEB) return " (Web)"; if (IS_VESKTOP) return ` (Vesktop v${VesktopNative.app.getVersion()})`; + if (IS_EQUIBOP) return `Equibop v${VesktopNative.app.getVersion()}`; if (IS_STANDALONE) return " (Standalone)"; return ""; }, diff --git a/src/plugins/devCompanion.dev/initWs.tsx b/src/plugins/devCompanion.dev/initWs.tsx index ae96d57f..f48812a3 100644 --- a/src/plugins/devCompanion.dev/initWs.tsx +++ b/src/plugins/devCompanion.dev/initWs.tsx @@ -315,7 +315,7 @@ export function initWs(isManual = false) { return reply("Expected exactly one 'find' matches, found " + keys.length); const mod = candidates[keys[0]]; - let src = String(mod.original ?? mod).replaceAll("\n", ""); + let src = String(mod).replaceAll("\n", ""); if (src.startsWith("function(")) { src = "0," + src;