add webpack injection
This commit is contained in:
parent
8eac634cb8
commit
b92d7226e4
5 changed files with 73 additions and 6 deletions
2
Makefile
2
Makefile
|
@ -28,4 +28,4 @@ out/css/base.css: src/style/base.less $(OSTYLES)
|
||||||
npx lessc $< > $@
|
npx lessc $< > $@
|
||||||
|
|
||||||
out/js/%.js: src/script/%.coffee
|
out/js/%.js: src/script/%.coffee
|
||||||
npx coffee --no-header -bco $@ $<
|
npx coffee --no-header -co $@ $<
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
|
|
||||||
"description": "Custom theme for Discord",
|
"description": "Custom theme for Discord",
|
||||||
|
|
||||||
"icons": {
|
|
||||||
"48": "ext.png"
|
|
||||||
},
|
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"https://raw.githubusercontent.com/Er2ch/diskort/*",
|
"https://raw.githubusercontent.com/Er2ch/diskort/*",
|
||||||
"*://discord.com/",
|
"*://discord.com/",
|
||||||
|
@ -21,6 +17,7 @@
|
||||||
"persistent": true
|
"persistent": true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"web_accessible_resources": ["js/webpack.js"],
|
||||||
"content_scripts": [{
|
"content_scripts": [{
|
||||||
"matches": ["*://discord.com/*"],
|
"matches": ["*://discord.com/*"],
|
||||||
"js": ["js/inj.js"]
|
"js": ["js/inj.js"]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"description": "Custom script and style engine for Discord",
|
"description": "Custom script and style engine for Discord",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"coffeescript": "^2.6.1",
|
"coffeescript": "^2.7.0",
|
||||||
"lessc": "^1.0.2"
|
"lessc": "^1.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,13 @@
|
||||||
base = 'https://raw.githubusercontent.com/Er2ch/diskort/main/'
|
base = 'https://raw.githubusercontent.com/Er2ch/diskort/main/'
|
||||||
|
|
||||||
inject = ->
|
inject = ->
|
||||||
|
# inject webpack reader
|
||||||
|
s = document.createElement 'script'
|
||||||
|
s.setAttribute 'type', 'text/javascript'
|
||||||
|
s.setAttribute 'src', chrome.extension.getURL 'js/webpack.js'
|
||||||
|
document.head.appendChild s
|
||||||
|
|
||||||
|
# inject style
|
||||||
try
|
try
|
||||||
resp = await fetch base + 'btfl.css'
|
resp = await fetch base + 'btfl.css'
|
||||||
text = await resp.text()
|
text = await resp.text()
|
||||||
|
|
63
src/script/webpack.coffee
Normal file
63
src/script/webpack.coffee
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
### 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()
|
Loading…
Reference in a new issue