Make Settings & Settings Page

This commit is contained in:
Vendicated 2022-08-31 04:07:16 +02:00
parent cb288e204d
commit 98cb301df5
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
18 changed files with 330 additions and 43 deletions

View file

@ -1,4 +1,5 @@
import Plugins from "plugins";
import { Settings } from "../api/settings";
import Logger from "../utils/logger";
import { Patch } from "../utils/types";
@ -7,7 +8,7 @@ const logger = new Logger("PluginManager", "#a6d189");
export const plugins = Plugins;
export const patches = [] as Patch[];
for (const plugin of Plugins) if (plugin.patches) {
for (const plugin of Plugins) if (plugin.patches && Settings.plugins[plugin.name].enabled) {
for (const patch of plugin.patches) {
patch.plugin = plugin.name;
if (!Array.isArray(patch.replacement)) patch.replacement = [patch.replacement];
@ -16,7 +17,7 @@ for (const plugin of Plugins) if (plugin.patches) {
}
export function startAll() {
for (const plugin of plugins) if (plugin.start) {
for (const plugin of plugins) if (plugin.start && Settings.plugins[plugin.name].enabled) {
try {
logger.info("Starting plugin", plugin.name);
plugin.start();

View file

@ -1,11 +1,12 @@
import { MessageClicks } from "../api";
import definePlugin from "../utils/types";
import { find, findByProps } from "../utils/webpack";
import { find, findByProps } from "../webpack";
export default definePlugin({
name: "MessageQuickActions",
description: "Quick Delete, Quick edit",
author: "Vendicated",
dependencies: ["MessageClicksApi"],
start() {
const { deleteMessage, startEditMessage } = findByProps("deleteMessage");
const { can } = findByProps("can", "initialize");

View file

@ -1,5 +1,5 @@
import definePlugin from "../utils/types";
import { findByProps } from "../utils/webpack";
import { findByProps } from "../webpack";
const DO_NOTHING = () => void 0;
@ -7,6 +7,7 @@ export default definePlugin({
name: "NoTrack",
description: "Disable Discord's tracking and crash reporting",
author: "Vendicated",
required: true,
start() {
findByProps("getSuperPropertiesBase64", "track").track = DO_NOTHING;
findByProps("submitLiveCrashReport").submitLiveCrashReport = DO_NOTHING;

View file

@ -5,6 +5,7 @@ export default definePlugin({
name: "Settings",
description: "Adds Settings UI and debug info",
author: "Vendicated",
required: true,
patches: [{
find: "default.versionHash",
replacement: [
@ -28,7 +29,7 @@ export default definePlugin({
}, {
find: "Messages.ACTIVITY_SETTINGS",
replacement: {
match: /\{section:(.{1,2})\.SectionTypes\.HEADER,label:(.{1,2})\.default\.Messages\.ACTIVITY_SETTINGS\}/,
match: /\{section:(.{1,2})\.SectionTypes\.HEADER,\s*label:(.{1,2})\.default\.Messages\.ACTIVITY_SETTINGS\}/,
replace: (m, mod) =>
`{section:${mod}.SectionTypes.HEADER,label:"Vencord"},` +
`{section:"Vencord",label:"Vencord",element:Vencord.Components.Settings},` +