diff options
author | Vendicated <vendicated@riseup.net> | 2022-09-27 14:34:57 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-09-27 14:34:57 +0200 |
commit | 6398dd25d20e6bc3e02425b709233066baf64e0c (patch) | |
tree | 3502593fdb4912c678ce6e840726114ccdb8c218 | |
parent | d0940a8b194805173dae029d0fe284974ffecc7a (diff) | |
download | Vencord-6398dd25d20e6bc3e02425b709233066baf64e0c.tar.gz Vencord-6398dd25d20e6bc3e02425b709233066baf64e0c.tar.bz2 Vencord-6398dd25d20e6bc3e02425b709233066baf64e0c.zip |
Unbrick Vencord - Pt 1
-rw-r--r-- | src/plugins/STFU.ts | 4 | ||||
-rw-r--r-- | src/plugins/apiMessageEvents.ts | 8 | ||||
-rw-r--r-- | src/plugins/cumcord.ts | 14 | ||||
-rw-r--r-- | src/plugins/ify.ts | 9 | ||||
-rw-r--r-- | src/plugins/messageActions.ts | 2 | ||||
-rw-r--r-- | src/plugins/noTrack.ts | 6 | ||||
-rw-r--r-- | src/plugins/settings.ts | 20 | ||||
-rw-r--r-- | src/utils/patchWebpack.ts | 8 | ||||
-rw-r--r-- | src/webpack/webpack.ts | 11 |
9 files changed, 34 insertions, 48 deletions
diff --git a/src/plugins/STFU.ts b/src/plugins/STFU.ts index ee9c90f..afa29f5 100644 --- a/src/plugins/STFU.ts +++ b/src/plugins/STFU.ts @@ -7,8 +7,8 @@ export default definePlugin({ patches: [{ find: "setDevtoolsCallbacks", replacement: { - match: /\.default=function.+$/, - replace: ".default=function(){}}" + match: /\.setDevtoolsCallbacks\(.+?else/, + replace: ".setDevtoolsCallbacks(null,null);else" } }] }); diff --git a/src/plugins/apiMessageEvents.ts b/src/plugins/apiMessageEvents.ts index 79acd32..98144e2 100644 --- a/src/plugins/apiMessageEvents.ts +++ b/src/plugins/apiMessageEvents.ts @@ -8,20 +8,20 @@ export default definePlugin({ { find: "sendMessage:function", replacement: [{ - match: /(?<=sendMessage:function\(.{1,2},.{1,2},.{1,2},.{1,2}\)){/, + match: /(?<=_sendMessage:function\([^)]+\)){/, replace: "{Vencord.Api.MessageEvents._handlePreSend(...arguments);" }, { - match: /(?<=editMessage:function\(.{1,2},.{1,2},.{1,2}\)){/, + match: /(?<=\beditMessage:function\([^)]+\)){/, replace: "{Vencord.Api.MessageEvents._handlePreEdit(...arguments);" }] }, { find: "if(e.altKey){", replacement: { - match: /\.useClickMessage=function\((.{1,2}),(.{1,2})\).+?function\((.{1,2})\){/, + match: /var \w=(\w)\.id,\w=(\w)\.id;return .{1,2}\.useCallback\(\(?function\((.{1,2})\){/, replace: (m, message, channel, event) => // the message param is shadowed by the event param, so need to alias them - `${m.replace("{", `{var _msg=${message};var _chan=${channel};`)}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});` + `var _msg=${message},_chan=${channel};${m}Vencord.Api.MessageEvents._handleClick(_msg, _chan, ${event});` } } ] diff --git a/src/plugins/cumcord.ts b/src/plugins/cumcord.ts deleted file mode 100644 index 626079b..0000000 --- a/src/plugins/cumcord.ts +++ /dev/null @@ -1,14 +0,0 @@ -import definePlugin from "../utils/types"; - -export default definePlugin({ - name: "cumcord", - description: "Loads cumcord. That's it", - author: "Vendicated", - async start() { - const cum = await fetch("https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js"); - (0, eval)(await cum.text()); - }, - stop() { - window.cumcord?.uninject(); - }, -}); diff --git a/src/plugins/ify.ts b/src/plugins/ify.ts index 76cfa59..e0d5481 100644 --- a/src/plugins/ify.ts +++ b/src/plugins/ify.ts @@ -7,17 +7,14 @@ export default definePlugin({ patches: [ { find: '.displayName="SpotifyStore"', - replacement: { + replacement: [{ match: /\.isPremium=.;/, replace: ".isPremium=true;", - }, - }, - { - find: '.displayName="SpotifyStore"', - replacement: ["SPEAKING", "VOICE_STATE_UPDATES", "MEDIA_ENGINE_SET_DESKTOP_SOURCE"].map(event => ({ + }, ...["SPEAKING", "VOICE_STATE_UPDATES", "MEDIA_ENGINE_SET_DESKTOP_SOURCE"].map(event => ({ match: new RegExp(`${event}:function\\(.\\){.+?}(,|}\\))`), replace: (_, ending) => `${event}:function(){}${ending}`, })), + ], }, ] }); diff --git a/src/plugins/messageActions.ts b/src/plugins/messageActions.ts index 42f2e2f..569d3a9 100644 --- a/src/plugins/messageActions.ts +++ b/src/plugins/messageActions.ts @@ -16,7 +16,7 @@ export default definePlugin({ start() { const { deleteMessage, startEditMessage } = findByProps("deleteMessage"); const { can } = findByProps("can", "initialize"); - const { Permissions: { MANAGE_MESSAGES } } = find(m => m.Permissions?.MANAGE_MESSAGES); + const { MANAGE_MESSAGES } = find(m => typeof m.MANAGE_MESSAGES === "bigint"); const { isEditing } = findByProps("isEditing"); document.addEventListener("keydown", keydown); diff --git a/src/plugins/noTrack.ts b/src/plugins/noTrack.ts index ff4b95c..49f542e 100644 --- a/src/plugins/noTrack.ts +++ b/src/plugins/noTrack.ts @@ -9,14 +9,14 @@ export default definePlugin({ { find: "TRACKING_URL:", replacement: { - match: /=\(0,.\.analyticsTrackingStoreMaker\)/, - replace: "=(function(){})", + match: /^.+$/, + replace: "()=>{}", }, }, { find: "window.DiscordSentry=", replacement: { - match: /window\.DiscordSentry=\(0,.\.initSentry\)\(\)/, + match: /window\.DiscordSentry=function.+\}\(\)/, replace: "", } } diff --git a/src/plugins/settings.ts b/src/plugins/settings.ts index 7d6af2d..1281f4e 100644 --- a/src/plugins/settings.ts +++ b/src/plugins/settings.ts @@ -7,33 +7,27 @@ export default definePlugin({ author: "Vendicated", required: true, patches: [{ - find: "default.versionHash", + find: "().versionHash", replacement: [ { - match: /return .{1,2}\("div"/, - replace: (m) => { - return `var versions=VencordNative.getVersions();${m}`; - } - }, - { - match: /\w\.createElement.+?["']Host ["'].+?\):null/, + match: /\w\.createElement\(.{1,2}.Fragment,.{0,30}\{[^}]+\},"Host ".+?\):null/, replace: m => { const idx = m.indexOf("Host") - 1; const template = m.slice(0, idx); return `${m}, ${template}"Vencord ", "${gitHash}"), " "), ` + - `${template} "Electron ", versions.electron), " "), ` + - `${template} "Chrome ", versions.chrome), " ")`; + `${template} "Electron ",VencordNative.getVersions().electron)," "), ` + + `${template} "Chrome ",VencordNative.getVersions().chrome)," ")`; } } ] }, { find: "Messages.ACTIVITY_SETTINGS", replacement: { - match: /\{section:(.{1,2})\.SectionTypes\.HEADER,\s*label:(.{1,2})\.default\.Messages\.ACTIVITY_SETTINGS\}/, + match: /\{section:(.{1,2})\.ID\.HEADER,\s*label:(.{1,2})\..{1,2}\.Messages\.ACTIVITY_SETTINGS\}/, replace: (m, mod) => - `{section:${mod}.SectionTypes.HEADER,label:"Vencord"},` + + `{section:${mod}.ID.HEADER,label:"Vencord"},` + `{section:"Vencord",label:"Vencord",element:Vencord.Components.Settings},` + - `{section:${mod}.SectionTypes.DIVIDER},${m}` + `{section:${mod}.ID.DIVIDER},${m}` } }] diff --git a/src/utils/patchWebpack.ts b/src/utils/patchWebpack.ts index 488e430..ce29c82 100644 --- a/src/utils/patchWebpack.ts +++ b/src/utils/patchWebpack.ts @@ -65,9 +65,11 @@ function patchPush() { if (filter(exports)) { subscriptions.delete(filter); callback(exports); - } else if (exports.default && filter(exports.default)) { - subscriptions.delete(filter); - callback(exports.default); + } else for (const nested in exports) { + if (exports[nested] && filter(exports[nested])) { + subscriptions.delete(filter); + callback(exports[nested]); + } } } catch (err) { logger.error("Error while firing callback for webpack chunk", err); diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 27306de..a1fd2fb 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -32,15 +32,22 @@ export function find(filter: FilterFn, getDefault = true) { for (const key in cache) { const mod = cache[key]; - if (mod?.exports && filter(mod.exports)) + if (!mod?.exports) continue; + + if (filter(mod.exports)) return mod.exports; - if (mod?.exports?.default && filter(mod.exports.default)) + if (mod.exports.default && filter(mod.exports.default)) return getDefault ? mod.exports.default : mod.exports; + for (const nestedMod in mod.exports) { + const nested = mod.exports[nestedMod]; + if (nested && filter(nested)) return nested; + } } return null; } +// TODO fix export function findAll(filter: FilterFn, getDefault = true) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got", filter); |