Skip to content

Instantly share code, notes, and snippets.

@TheFauxFox
Last active May 11, 2023 01:14
Show Gist options
  • Save TheFauxFox/81f695134294331de1410952108f3673 to your computer and use it in GitHub Desktop.
Save TheFauxFox/81f695134294331de1410952108f3673 to your computer and use it in GitHub Desktop.
A toolbox for discord modules to break into their internals
Toolbox = (()=>{
this.webpack = webpackChunkdiscord_app.push([[Math.random()], 0, x => x])
this.modules = Object.values(webpack.c)
filter = (props, filterFunc, first = false) => {
let output = []
for (let module of modules) {
if (exports = module.exports) {
if (mod = exports.default || exports.Z) {
if (filterFunc(props, mod)) {
if (first) {
return mod
}
output.push(mod)
}
}
if (filterFunc(props, exports)) {
if (first) {
return exports
}
output.push(exports)
}
}
}
return output
}
modFilters = {
prop: (props, module) => props.every(prop => module[prop] != undefined),
proto: (protoProps, module) => {
if (!module.prototype) {
return false
}
return protoProps.every(prop => module.prototype[prop] != undefined)
},
regex: (regex, module) => module.toString().search(regex) != -1,
string: (strings, module) => strings.every(str => module.toString().includes(str)),
name: (name, module) => module.displayName == name || module.name == name
}
getModule = {
byProps: (...props) => filter(props, modFilters.prop, true),
byPropsAll: (...props) => filter(props, modFilters.prop),
byProto: (...props) => filter(props, modFilters.proto, true),
byProtoAll: (...props) => filter(props, modFilters.proto),
byRegex: (regex) => filter(regex, modFilters.regex, true),
byRegexAll: (regex) => filter(regex, modFilters.regex),
byString: (...string) => filter(string, modFilters.string, true),
byStringAll: (...string) => filter(string, modFilters.string),
byName: (name) => filter(name, modFilters.name, true),
byNameAll: (name) => filter(name, modFilters.name)
}
return {
getModule
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment