From 6398dd25d20e6bc3e02425b709233066baf64e0c Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 27 Sep 2022 14:34:57 +0200 Subject: Unbrick Vencord - Pt 1 --- src/plugins/STFU.ts | 4 ++-- src/plugins/apiMessageEvents.ts | 8 ++++---- src/plugins/cumcord.ts | 14 -------------- src/plugins/ify.ts | 9 +++------ src/plugins/messageActions.ts | 2 +- src/plugins/noTrack.ts | 6 +++--- src/plugins/settings.ts | 20 +++++++------------- 7 files changed, 20 insertions(+), 43 deletions(-) delete mode 100644 src/plugins/cumcord.ts (limited to 'src/plugins') 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}` } }] -- cgit