Skip to content

Instantly share code, notes, and snippets.

@Cynosphere
Created January 23, 2026 20:19
Show Gist options
  • Select an option

  • Save Cynosphere/93021bb631fdf9f1415cce2cd1e4c04a to your computer and use it in GitHub Desktop.

Select an option

Save Cynosphere/93021bb631fdf9f1415cce2cd1e4c04a to your computer and use it in GitHub Desktop.
Force load all chunks for Discord
(async () => {
const webpackRequire = webpackChunkdiscord_app.push([[Symbol()], {}, (r) => r]);
webpackChunkdiscord_app.pop();
let chunkUrl;
try {
webpackRequire("invalidmodule" + Math.random())
} catch(e) {
chunkUrl = e.stack.match(navigator.userAgent.includes("Firefox") ? /__webpack_require__@(https:\/\/.*?discord\.com\/assets\/web\..+?\.js).*?:/ : /at .*?__webpack_require__.*?\((https:\/\/.*?discord\.com\/assets\/web\..+?\.js).*?\)/)?.[1];
}
if (!chunkUrl) return;
const script = await fetch(chunkUrl + "?inj").then(res=>res.text());
const chunkIds = new Set(
script.match(/__webpack_require__\.u=.=>""\+\({(.+?)}\)\[/)[1]
.match(/(\d+([e]\d+)?)(:"[a-z0-9]+")/g)
.map((x) => Number(x.match(/(\d+([e]\d+)?)(:"[a-z0-9]+")/)[1]).toString()),
);
let expectedChunkCount = chunkIds.size;
let loaded = [];
for (const [ids] of window.webpackChunkdiscord_app) {
loaded.push(...ids);
}
for (const id of loaded) {
chunkIds.delete(id);
}
for (const id of chunkIds) {
const scriptPath = webpackRequire.u(id);
if (scriptPath == "undefined.js") {
console.error(`Got a bad script path for id "${id}"`);
chunkIds.delete(id);
expectedChunkCount--;
} else {
const content = await fetch(webpackRequire.p + webpackRequire.u(id)).then((res) => res.text());
if (content.includes("importScripts(") || content.includes(".postMessage(")) {
console.log(`Ignoring chunk "${id}": service worker`);
chunkIds.delete(id);
expectedChunkCount--;
}
}
}
for (const id of chunkIds) {
try {
console.log(`Force loading chunk "${id}"`);
await webpackRequire.e(id);
} catch (err) {
console.error(`Failed to load chunk ${id}:`, err.toString());
}
}
console.log(expectedChunkCount, window.webpackChunkdiscord_app.flatMap((c) => c[1]).length);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment