How qeqqe/vencord works
Project type and purpose
• Vencord is a client-side modification framework for Discord. It targets two runtime environments:
• Browser (as an extension or userscript)
• Desktop (via an Electron-style wrapper that patches the official Discord client)
• Its purpose is to inject a plugin system, UI enhancements, settings sync, and custom theming into Discord without altering Discord’s server-side code.
File structure
• Top-level directories:
• browser/ – content scripts, background scripts, manifest files for the web extension/userscript
• src/main/ – the desktop “main process” code (patcher, updater, IPC handlers, theme loader)
• src/preload.ts – code injected into the Discord renderer process in desktop builds
• src/webpack/ & scripts/build/ – bundling and patch application pipelines for both browser and desktop
• src/api, src/components, src/plugins – the runtime API surface, React UI components, and built-in plugins
• shared/ & utils/ – cross-context helpers (IPC event definitions, settings storage, debounce, lazy loading, etc.)
• scripts/ – build, test, packaging, version checks, installer generator
• Configuration files: package.json, pnpm-workspace.yaml, tsconfig.json, webpack config, build scripts, patch files under patches/
README for additional insights
• Vencord provides:
• An installer GUI for desktop
• 100+ built-in plugins and a plugin API for third-party authors
• Settings synchronization across devices
• A CSS theme editor
• A privacy-focused patcher that blocks telemetry/crash reporting
• Underlying stack: TypeScript, React (TSX), PNPM, Webpack, Electron-like IPC
a. Main components
• Build Pipeline
– scripts/build & webpack → generate browser extension bundle and desktop patch + preload script
– patches/ applied to Discord’s JavaScript assets
• Desktop Runtime (Electron style)
– Main Process (src/main)
· Patcher module loads Discord’s code, applies patches, spawns renderer
· Updater (HTTP/Git), settings store, theme loader
· IPC Main endpoints for renderer
– Preload Script (src/preload.ts)
· Exposes IPC Renderer API, plugin loader entrypoint, settings sync hooks
– Renderer Process (Discord UI + injected Vencord code)
· React components (src/components, src/api) render settings UI, plugin UI, etc.
· Plugin Loader scans src/plugins and user-installed plugins, injects their code
· Settings Store (shared/SettingsStore.ts) persists to local storage or cloud
• Browser Runtime
– Extension Background Script (browser/background.js)
– Content Script (browser/content.js) injects Vencord loader into discord.com pages
– GMPolyfill & userscript stubs to unify APIs with desktop preload
• External Services
– Plugin repository API (vencord.dev/plugins) for plugin metadata
– Settings sync server (optional cloud)
– Update distribution endpoints
b. Relationships and interactions
• Build Pipeline → produces Desktop Bundle & Browser Extension
• Desktop Main Process ↔ Preload Script via internal module imports
• Preload Script ↔ Renderer via IPC channels defined in shared/IpcEvents.ts
• Renderer ↔ Plugins (dynamic require + React render injection)
• Renderer ↔ Settings Sync Server (via HTTP)
• Browser Background → Content Script → injected loader → Renderer
c. Architectural patterns and principles
• Modular plugin architecture: each plugin folder under src/plugins is a self-contained module following a common API
• IPC boundary between untrusted renderer (Discord UI) and trusted main logic (patching, file access, updater)
• Build-time patch application: patches/ directory holds source patches for 3rd-party libraries (ESLint, etc.)
• Single-page overlay injections: Vencord UI is injected atop Discord’s SPA shell
d. Key technologies and frameworks
• TypeScript + TSX (React)
• Webpack bundling with custom patchWebpack logic
• PNPM workspaces (packages/vencord-types)
• Electron-style IPC (src/shared/IpcEvents.ts)
• Browser extension manifests (manifest.json, userscript.meta.js)
• Local storage & cloud sync (shared/SettingsStore.ts)