64 lines
1.4 KiB
CoffeeScript
64 lines
1.4 KiB
CoffeeScript
### DisKort
|
|
# (c) Er2 2022
|
|
# Zlib License
|
|
###
|
|
|
|
# Find and use Discord obfuscated webpack modules
|
|
window.webpack = {}
|
|
|
|
# Helper functions
|
|
window.ModGetsAll = =>
|
|
Object.values webpack.cache
|
|
.filter (m) => m.exports
|
|
|
|
window.ModGet = (filt, first = true) =>
|
|
if Array.isArray filt
|
|
key = filt
|
|
filt = (m) => key.every (k) => m.hasOwnProperty(k) or (m.__proto__ and m.__proto__.hasOwnProperty k)
|
|
|
|
mods = ModGetsAll()
|
|
m = []
|
|
for i of mods
|
|
continue if not mods.hasOwnProperty i
|
|
mod = mods[i]
|
|
{exports} = mod
|
|
continue if not exports
|
|
exports = exports.default if exports.default
|
|
continue if not filt exports
|
|
return exports if first
|
|
m.push exports
|
|
|
|
first or m.length is 0 and null or m
|
|
|
|
window.ModGets = (filt) =>
|
|
ModGet filt, false
|
|
|
|
window.ModGetName = (name, ret, forev) =>
|
|
ModGet (m) => m.displayName?.toLowerCase() is name.toLowerCase()
|
|
|
|
window.WinProps = =>
|
|
platform: window.platform
|
|
GLOBAL_ENV: window.GLOBAL_ENV
|
|
DiscordSentry: window.DiscordSentry
|
|
__SENTRY__: window.__SENTRY__
|
|
|
|
console.log 'Welcome to DisKort!'
|
|
|
|
init = =>
|
|
while not window.webpackChunkdiscord_app or not window._
|
|
await new Promise (res) => setTimeout res, 100
|
|
|
|
console.log 'Ready to inject'
|
|
|
|
webpackChunkdiscord_app.push [
|
|
[[ 'diskort' ]]
|
|
{}
|
|
(r) =>
|
|
webpack.cache = r.c
|
|
webpack.require = (m) => r m
|
|
return
|
|
]
|
|
return
|
|
|
|
init()
|