Skip to content

Instantly share code, notes, and snippets.

@wavedevgit
Created January 26, 2026 21:34
Show Gist options
  • Select an option

  • Save wavedevgit/dfeb8801b70cb8d363380a9580ec276b to your computer and use it in GitHub Desktop.

Select an option

Save wavedevgit/dfeb8801b70cb8d363380a9580ec276b to your computer and use it in GitHub Desktop.
discord client shims

You need:

findChunkByCode:

let wreq = webpackChunkdiscord_app.push([[Symbol()],{},r=>r]);
webpackChunkdiscord_app.pop();
const chunks = Object.entries(wreq.m)
const findChunkByCode = (...codes) => {
    for (let i = 0; i < chunks.length; i++) {
        const [id,func] = chunks[i]
        const chunkCode = func.toString()

        if (codes.every(code=>chunkCode.includes(code))) return wreq(id)
    }
}

findByProps:

let _mods = webpackChunkdiscord_app.push([[Symbol()],{},r=>r.c]);
webpackChunkdiscord_app.pop();

let findByProps = (...props) => {
    for (let m of Object.values(_mods)) {
        try {
            if (!m.exports || m.exports === window) continue;
            if (props.every((x) => m.exports?.[x])) return m.exports;

            for (let ex in m.exports) {
                if (props.every((x) => m.exports?.[ex]?.[x]) && m.exports[ex][Symbol.toStringTag] !== 'IntlMessagesProxy') return m.exports[ex];
            }
        } catch {}
    }
}
// dynamic values
const generateShimsObject = (exports) => {
let shimsObject = {};
for (let key in exports)
Object.defineProperty(shimsObject, key, { get: exports[key] });
return shimsObject;
};
const shims = generateShimsObject({
murmurhash: () => findByProps('v2', 'v3'),
react: () => findByProps('PureComponent', 'createElement', 'Fragment'),
ieee754: () => findByProps('write', 'read'),
events: () => findChunkByCode(',"defaultMaxListeners"'),
url: () => findByProps('resolveObject', 'Url'),
punycode: () => findByProps('toASCII', 'encode'),
'object-assign': () =>
findChunkByCode(
'Object.assign cannot be called with null or undefined',
),
// you'll never need this anyways but here it is
isarray: () => findChunkByCode('Array.isArray||'),
util: () => findByProps('deprecate', 'format', 'debuglog'),
'sdp-transform': () => findByProps('parseParams', 'grammar'),
'query-string': () => findByProps('stringify', 'parse', 'extract'),
'path-to-regexp': () => findByProps('compile', 'tokensToRegExp', 'parse'),
pako: () => findByProps('gzip', 'Deflate'),
process: () => findByProps('argv', 'env', 'browser'),
'promise-timeout': () => findByProps('timeout', 'TimeoutError'),
pseudomap: () => findChunkByCode("Constructor PseudoMap requires 'new"),
platform: () => findByProps('parse', 'os', 'ua'),
semver: () => findByProps('SEMVER_SPEC_VERSION'),
'react/jsx-runtime': () => findByProps('jsxs', 'jsx'),
'react-dom': () => findByProps('createPortal', 'useFormState'),
'intl-messageformat-parser': () => findByProps('parse', 'SyntaxError'),
'intl-messageformat': () =>
findByProps('formats', '__addLocaleData', '__parse'),
'fast-safe-stringify': () => findByProps('stableStringify', 'stable'),
'ip-regex': () =>
findChunkByCode('// 1:2:3:4:5:6:7::', '.includeBoundaries'),
'is-plain-object': () =>
findChunkByCode(
'Object.prototype.toString.call',
'.constructor',
'hasOwnProperty("isPrototypeOf")',
),
'Iru-cache': () => findChunkByCode('.rforEach='),
'react-is': () => findByProps('isMemo', 'isValidElementType'),
yallist: () => findChunkByCode('.removeNode=', '.tail=null'),
intl: () => findByProps('NumberFormat'),
history: () => findChunkByCode('.getUserConfirmation', 'PUSH'),
'react-dom/client': () => findByProps('createRoot'),
'@intrnl/xxhash64': () => findByProps('XXH64', 'hash'),
moment: () => findByProps('isMoment'),
'double-ended-queue': () =>
findChunkByCode('this._capacity=', 'this._front=0', 'toJSON'),
'decimal.js': () => findByProps('precision', 'LN10'),
'chroma-js': () => findByProps('brewer'),
lodash: () => findByProps('forEachRight'),
buffer: () => findByProps('INSPECT_MAX_BYTES', 'Buffer'),
'decode-uri-component': () =>
findChunkByCode('Expected `encodedURI` to be of'),
'dependency-graph': () => findByProps('DepGraph'),
superagent: () => findByProps('get', 'put', 'del', 'patch', 'post'),
'strict-uri-encode': () =>
findChunkByCode('.toString(16', 'encodeURIComponent'),
'tiny-invariant': () => findChunkByCode('Invariant failed'),
'simple-markdown': () => findByProps('defaultParse'),
'@discordapp/twemoji': () => findByProps('base', 'parse', 'replace'),
'@discord/intl': () => findByProps('createLoader', 'runtimeHashMessageKey'),
'base64-js': () => findByProps('toByteArray'),
humanize: () => findByProps('noConflict', 'pad', 'time'),
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment