-
Notifications
You must be signed in to change notification settings - Fork 27
Asset Loader
Asset loader is a system designed to handle the downloading, synchronizing, loading, and hot-reloading of external resources like scripts and themes.
By default, it is used to load client mods and renderer scripts.
All assets are stored locally in the assets subdirectory of the main data folder, which you can open through the settings.
On startup, GoofCord scans this folder to load your themes and client modifications.
There are two ways to add files to the client: using the External Assets setting for automatic updates, or manually dropping files into the folder.
This is the recommended method to keep frequently updating assets (like Vencord) up to date.
In the "Add" button dropdown, you can either choose one of the presets, or create a custom entry.
Keys must be unique.
- How it works: On startup, the client checks the URLs defined in your settings against the files on your disk.
-
Network Updates: If a remote file has changed (detected via
ETagheaders), the client downloads the new version automatically. -
Local Synchronization: You can point an asset URL to a local file path (e.g.,
file:///C:/MyProjects/theme.css). The client will copy the file into the assets folder whenever the source file changes. -
Garbage Collection: If you remove an entry from your configuration, the specific file associated with it will be automatically deleted from the
assetsfolder to keep it clean.
You can simply put .css or .js files into the assets/ folder.
- Note: Files added manually are safe. The garbage collector only removes files that were previously managed by the config and then removed.
CSS files are used for themes and visual customizations.
-
Hot Reloading: The Asset Loader includes a File Watcher. If you edit a
.cssfile inside theassetsfolder while the client is running, the changes will apply immediately without requiring a restart.
JavaScript files are used for client modifications and other custom scripts.
- Loading: Scripts are loaded into memory when the application starts.
-
Updates: Unlike CSS, modifying a
.jsfile requires a full restart for changes to take effect.
By default, GoofCord also loads two "renderer" scripts, PreVencord and PostVencord.
These files add core functionality and allow GoofCord to communicate with Discord. They are also tightly coupled with Vencord, and so need 2 stages to properly hook it.
They are built from src/windows/main/renderer/
To determine what script is what, GoofCord performs a header scan of the first 500 characters of the file content, looking for specific "Magic Strings" or markers:
-
Pre-Vencord:
prevencordmarker -
Vencord/Equicord:
vencord-
Note: Equicord also has
vencordin its header. If multiple markers are found, asset loader will only load the last one found, as there should be only a single Vencord-based client mod.
-
Note: Equicord also has
-
Post-Vencord:
postvencordmarker - Others: None
Note: If the Pre, Vencord, or Post scripts are missing during the scan, a "Critical Assets Missing" alert will be shown. GoofCord can work without the triad, but a lot of the functionality will be broken.
When the Asset Downloader fetches files from a URL, it generates a local filename to ensure filesystem compatibility:
-
Sanitization: Special characters in the asset name are replaced with underscores
_(e.g.,My-Script!becomesMy_Script_). -
Extension Inference: The downloader parses the URL path to find an extension.
- If the path ends in
.css, it is saved as a stylesheet. - If the path ends in anything else (or cannot be determined), it defaults to
.js. -
Fallback: If URL parsing fails entirely, it inspects the raw string; if that doesn't end in
.css, it logs a warning and forces.js.
- If the path ends in