Unbrick Vencord - Pt 1
This commit is contained in:
parent
d0940a8b19
commit
6398dd25d2
|
@ -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"
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
|
|
@ -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});`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
});
|
|
@ -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}`,
|
||||
})),
|
||||
],
|
||||
},
|
||||
]
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: "",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}`
|
||||
|
||||
}
|
||||
}]
|
||||
|
|
|
@ -65,9 +65,11 @@ function patchPush() {
|
|||
if (filter(exports)) {
|
||||
subscriptions.delete(filter);
|
||||
callback(exports);
|
||||
} else if (exports.default && filter(exports.default)) {
|
||||
} else for (const nested in exports) {
|
||||
if (exports[nested] && filter(exports[nested])) {
|
||||
subscriptions.delete(filter);
|
||||
callback(exports.default);
|
||||
callback(exports[nested]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error("Error while firing callback for webpack chunk", err);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue