Finish rewrite
This commit is contained in:
parent
c39ff8f648
commit
483bc13a31
9
README.md
Normal file
9
README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Vencord
|
||||||
|
|
||||||
|
My own Discord Desktop mod :)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Proper context isolation -> Works in newer Electron versions
|
||||||
|
- Inline patches: Patch Discord's code with regex replacements! See [the experiments plugin](src/plugins/experiments.ts) for an example. While being more complex, this is more powerful than monkey patching since you can patch only small parts of functions instead of fully replacing them, access non exported/local variables and even replace constants (like in the aforementioned experiments patch!)
|
||||||
|
- Custom Css: Manually edit `%appdata%/Vencord/settings/quickCss.css` / `~/.config/Vencord/settings/quickCss.css` with your favourite editor and the client will automatically apply your changes
|
@ -97,7 +97,8 @@ await Promise.all([
|
|||||||
globPlugins
|
globPlugins
|
||||||
],
|
],
|
||||||
sourcemap: "inline",
|
sourcemap: "inline",
|
||||||
watch
|
watch,
|
||||||
|
minify: true
|
||||||
})
|
})
|
||||||
]).then(res => {
|
]).then(res => {
|
||||||
const took = performance.now() - begin;
|
const took = performance.now() - begin;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import * as plugins from "./plugins";
|
export * as Plugins from "./plugins";
|
||||||
import * as WP from "./utils/webpack";
|
export * as Webpack from "./utils/webpack";
|
||||||
|
export * as Api from "./api";
|
||||||
|
|
||||||
import "./utils/patchWebpack";
|
import "./utils/patchWebpack";
|
||||||
import "./utils/quickCss";
|
import "./utils/quickCss";
|
||||||
|
|
||||||
export const Webpack = WP;
|
|
||||||
export const Plugins = plugins;
|
|
17
src/api/MessageClicks.ts
Normal file
17
src/api/MessageClicks.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
type Listener = (message, channel, event) => void;
|
||||||
|
|
||||||
|
const listeners = new Set<Listener>();
|
||||||
|
|
||||||
|
export function _handleClick(message, channel, event) {
|
||||||
|
for (const listener of listeners) {
|
||||||
|
listener(message, channel, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addListener(listener: Listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeListener(listener: Listener) {
|
||||||
|
return listeners.delete(listener);
|
||||||
|
}
|
1
src/api/index.ts
Normal file
1
src/api/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * as MessageClicks from "./MessageClicks";
|
1
src/globals.d.ts
vendored
1
src/globals.d.ts
vendored
@ -10,6 +10,7 @@ declare global {
|
|||||||
push(chunk: any): any;
|
push(chunk: any): any;
|
||||||
pop(): any;
|
pop(): any;
|
||||||
};
|
};
|
||||||
|
[k: PropertyKey]: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/plugins/STFU.ts
Normal file
10
src/plugins/STFU.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import definePlugin from "../utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "STFU",
|
||||||
|
description: "Disabled the fat warning in the DevTools console",
|
||||||
|
author: "Vendicated",
|
||||||
|
start() {
|
||||||
|
window.DiscordNative.window.setDevtoolsCallbacks(null, null);
|
||||||
|
}
|
||||||
|
});
|
16
src/plugins/apiMessageClicks.ts
Normal file
16
src/plugins/apiMessageClicks.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import definePlugin from "../utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "MessageClicksApi",
|
||||||
|
description: "Api required by anything using message click actions",
|
||||||
|
author: "Vendicated",
|
||||||
|
patches: [{
|
||||||
|
find: "if(e.altKey){",
|
||||||
|
replacement: {
|
||||||
|
match: /\.useClickMessage=function\((.{1,2}),(.{1,2})\).+?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.MessageClicks._handleClick(_msg, _chan, ${event});`
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
@ -1,10 +0,0 @@
|
|||||||
import definePlugin from '../utils/types';
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "bar",
|
|
||||||
description: "Just to test",
|
|
||||||
author: ["Vendicated"],
|
|
||||||
start() {
|
|
||||||
console.log("bar");
|
|
||||||
}
|
|
||||||
});
|
|
17
src/plugins/clientInfo.ts
Normal file
17
src/plugins/clientInfo.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import definePlugin from "../utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "ClientInfo",
|
||||||
|
description: "Adds extra info to Client Info in settings",
|
||||||
|
author: "Vendicated",
|
||||||
|
patches: [{
|
||||||
|
find: "default.versionHash",
|
||||||
|
replacement: {
|
||||||
|
match: /\w\.createElement.+?["']Host ["'].+?\):null/,
|
||||||
|
replace: m => {
|
||||||
|
const idx = m.indexOf("Host") - 1;
|
||||||
|
return `${m},${m.slice(0, idx)}"Vencord ".repeat(50),"1.0.0")," ")`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
14
src/plugins/experiments.ts
Normal file
14
src/plugins/experiments.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import definePlugin from '../utils/types';
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "Experiments",
|
||||||
|
author: "Vendicated",
|
||||||
|
description: "Enable Experiments",
|
||||||
|
patches: [{
|
||||||
|
find: "Object.defineProperties(this,{isDeveloper",
|
||||||
|
replacement: {
|
||||||
|
match: /(?<={isDeveloper:\{[^}]+,get:function\(\)\{return )\w/,
|
||||||
|
replace: "true"
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
@ -1,10 +0,0 @@
|
|||||||
import definePlugin from "../utils/types";
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "foo",
|
|
||||||
description: "Just to test",
|
|
||||||
author: ["Vendicated"],
|
|
||||||
start() {
|
|
||||||
console.log("foo");
|
|
||||||
}
|
|
||||||
});
|
|
36
src/plugins/messageActions.ts
Normal file
36
src/plugins/messageActions.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { MessageClicks } from "../api";
|
||||||
|
import definePlugin from "../utils/types";
|
||||||
|
import { find, findByProps } from "../utils/webpack";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "MessageQuickActions",
|
||||||
|
description: "Quick Delete, Quick edit",
|
||||||
|
author: "Vendicated",
|
||||||
|
start() {
|
||||||
|
const { deleteMessage, startEditMessage } = findByProps("deleteMessage");
|
||||||
|
const { can } = findByProps("can", "initialize");
|
||||||
|
const { Permissions: { MANAGE_MESSAGES } } = find(m => m.Permissions?.MANAGE_MESSAGES);
|
||||||
|
const { getCurrentUser } = findByProps("getCurrentUser");
|
||||||
|
|
||||||
|
let isDeletePressed = false;
|
||||||
|
document.addEventListener("keydown", e => {
|
||||||
|
if (e.key === "Backspace") isDeletePressed = true;
|
||||||
|
});
|
||||||
|
document.addEventListener("keyup", e => {
|
||||||
|
if (e.key === "Backspace") isDeletePressed = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
MessageClicks.addListener((msg, chan, event) => {
|
||||||
|
const isMe = msg.author.id === getCurrentUser().id;
|
||||||
|
if (!isDeletePressed) {
|
||||||
|
if (isMe && event.detail >= 2) {
|
||||||
|
startEditMessage(chan.id, msg.id, msg.content);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
} else if (isMe || can(MANAGE_MESSAGES, chan)) {
|
||||||
|
deleteMessage(chan.id, msg.id);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
31
src/plugins/noTrack.ts
Normal file
31
src/plugins/noTrack.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import definePlugin from "../utils/types";
|
||||||
|
import { findByProps } from "../utils/webpack";
|
||||||
|
|
||||||
|
const DO_NOTHING = () => void 0;
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "NoTrack",
|
||||||
|
description: "Disable Discord's tracking and crash reporting",
|
||||||
|
author: "Vendicated",
|
||||||
|
start() {
|
||||||
|
findByProps("getSuperPropertiesBase64", "track").track = DO_NOTHING;
|
||||||
|
findByProps("submitLiveCrashReport").submitLiveCrashReport = DO_NOTHING;
|
||||||
|
findByProps("AnalyticsActionHandlers").AnalyticsActionHandlers.handleTrack = DO_NOTHING;
|
||||||
|
|
||||||
|
const sentry = window.__SENTRY__;
|
||||||
|
sentry.logger.disable();
|
||||||
|
|
||||||
|
sentry.hub.addBreadcrumb = DO_NOTHING;
|
||||||
|
sentry.hub.getClient().close(0);
|
||||||
|
sentry.hub.getScope().clear();
|
||||||
|
|
||||||
|
const c = console;
|
||||||
|
for (const method in c) {
|
||||||
|
if (c[method].__sentry_original__)
|
||||||
|
c[method] = c[method].__sentry_original__;
|
||||||
|
if (c[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__?.__sentry_original__)
|
||||||
|
c[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__ = c[method].__REACT_DEVTOOLS_ORIGINAL_METHOD__.__sentry_original__;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
// exists to export default definePlugin({...})
|
// exists to export default definePlugin({...})
|
||||||
export default function definePlugin(p: Plugin) {
|
export default function definePlugin(p: PluginDef) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,7 +17,12 @@ export interface Patch {
|
|||||||
export interface Plugin {
|
export interface Plugin {
|
||||||
name: string;
|
name: string;
|
||||||
description: string;
|
description: string;
|
||||||
author: string[];
|
author: string;
|
||||||
start?(): void;
|
start?(): void;
|
||||||
patches?: Patch[];
|
patches?: Patch[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore lole
|
||||||
|
interface PluginDef extends Plugin {
|
||||||
|
patches?: Omit<Patch, "plugin">[];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user