mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-25 08:46:25 +00:00
Merge branch 'dev' into Warning
This commit is contained in:
commit
1c0a4aa2a8
7 changed files with 45 additions and 97 deletions
|
@ -25,10 +25,9 @@ import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
|||
import type { UserThemeHeader } from "@main/themes";
|
||||
import { openInviteModal } from "@utils/discord";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { classes } from "@utils/misc";
|
||||
import { showItemInFolder } from "@utils/native";
|
||||
import { useAwaiter } from "@utils/react";
|
||||
import { findByPropsLazy, findLazy } from "@webpack";
|
||||
import { findLazy } from "@webpack";
|
||||
import { Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
|
||||
import type { ComponentType, Ref, SyntheticEvent } from "react";
|
||||
|
||||
|
@ -45,9 +44,7 @@ type FileInput = ComponentType<{
|
|||
filters?: { name?: string; extensions: string[]; }[];
|
||||
}>;
|
||||
|
||||
const InviteActions = findByPropsLazy("resolveInvite");
|
||||
const FileInput: FileInput = findLazy(m => m.prototype?.activateUploadDialogue && m.prototype.setRef);
|
||||
const TextAreaProps = findLazy(m => typeof m.textarea === "string");
|
||||
|
||||
const cl = classNameFactory("vc-settings-theme-");
|
||||
|
||||
|
@ -306,7 +303,7 @@ function ThemesTab() {
|
|||
<TextArea
|
||||
value={themeText}
|
||||
onChange={setThemeText}
|
||||
className={classes(TextAreaProps.textarea, "vc-settings-theme-links")}
|
||||
className={"vc-settings-theme-links"}
|
||||
placeholder="Theme Links"
|
||||
spellCheck={false}
|
||||
onBlur={onBlur}
|
||||
|
|
|
@ -33,6 +33,20 @@
|
|||
padding: 0.5em;
|
||||
border: 1px solid var(--background-modifier-accent);
|
||||
max-height: unset;
|
||||
background-color: transparent;
|
||||
box-sizing: border-box;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
resize: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.vc-settings-theme-links::placeholder {
|
||||
color: var(--header-secondary);
|
||||
}
|
||||
|
||||
.vc-settings-theme-links:focus {
|
||||
background-color: var(--background-tertiary);
|
||||
}
|
||||
|
||||
.vc-cloud-settings-sync-grid {
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# AutomodContext
|
||||
|
||||
Allows you to jump to the messages surrounding an automod hit
|
||||
|
||||
![Visualization](https://github.com/Vendicated/Vencord/assets/61953774/d13740c8-2062-4553-b975-82fd3d6cc08b)
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Button, ChannelStore, Text } from "@webpack/common";
|
||||
|
||||
const { selectChannel } = findByPropsLazy("selectChannel", "selectVoiceChannel");
|
||||
|
||||
function jumpToMessage(channelId: string, messageId: string) {
|
||||
const guildId = ChannelStore.getChannel(channelId)?.guild_id;
|
||||
|
||||
selectChannel({
|
||||
guildId,
|
||||
channelId,
|
||||
messageId,
|
||||
jumpType: "INSTANT"
|
||||
});
|
||||
}
|
||||
|
||||
function findChannelId(message: any): string | null {
|
||||
const { embeds: [embed] } = message;
|
||||
const channelField = embed.fields.find(({ rawName }) => rawName === "channel_id");
|
||||
|
||||
if (!channelField) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return channelField.rawValue;
|
||||
}
|
||||
|
||||
export default definePlugin({
|
||||
name: "AutomodContext",
|
||||
description: "Allows you to jump to the messages surrounding an automod hit.",
|
||||
authors: [Devs.JohnyTheCarrot],
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: ".Messages.GUILD_AUTOMOD_REPORT_ISSUES",
|
||||
replacement: {
|
||||
match: /\.Messages\.ACTIONS.+?}\)(?=,(\(0.{0,40}\.dot.*?}\)),)/,
|
||||
replace: (m, dot) => `${m},${dot},$self.renderJumpButton({message:arguments[0].message})`
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
renderJumpButton: ErrorBoundary.wrap(({ message }: { message: any; }) => {
|
||||
const channelId = findChannelId(message);
|
||||
|
||||
if (!channelId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
style={{ padding: "2px 8px" }}
|
||||
look={Button.Looks.LINK}
|
||||
size={Button.Sizes.SMALL}
|
||||
color={Button.Colors.LINK}
|
||||
onClick={() => jumpToMessage(channelId, message.id)}
|
||||
>
|
||||
<Text color="text-link" variant="text-xs/normal">
|
||||
Jump to Surrounding
|
||||
</Text>
|
||||
</Button>
|
||||
);
|
||||
}, { noop: true })
|
||||
});
|
|
@ -35,6 +35,7 @@ export default definePlugin({
|
|||
if (hasCtrl) switch (e.key) {
|
||||
case "t":
|
||||
case "T":
|
||||
if (!IS_VESKTOP) return;
|
||||
e.preventDefault();
|
||||
if (e.shiftKey) {
|
||||
if (SelectedGuildStore.getGuildId()) NavigationRouter.transitionToGuild("@me");
|
||||
|
@ -47,14 +48,15 @@ export default definePlugin({
|
|||
});
|
||||
}
|
||||
break;
|
||||
case "Tab":
|
||||
if (!IS_VESKTOP) return;
|
||||
const handler = e.shiftKey ? KeyBinds.SERVER_PREV : KeyBinds.SERVER_NEXT;
|
||||
handler.action(e);
|
||||
break;
|
||||
case ",":
|
||||
e.preventDefault();
|
||||
SettingsRouter.open("My Account");
|
||||
break;
|
||||
case "Tab":
|
||||
const handler = e.shiftKey ? KeyBinds.SERVER_PREV : KeyBinds.SERVER_NEXT;
|
||||
handler.action(e);
|
||||
break;
|
||||
default:
|
||||
if (e.key >= "1" && e.key <= "9") {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -233,7 +233,7 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
|
|||
logger.error("Error while firing callback for Webpack subscription:\n", err, filter, callback);
|
||||
}
|
||||
}
|
||||
} as any as { toString: () => string, original: any, (...args: any[]): void; };
|
||||
} as any as { toString: () => string, original: any, (...args: any[]): void; $$vencordPatchedSource?: string; };
|
||||
|
||||
factory.toString = originalMod.toString.bind(originalMod);
|
||||
factory.original = originalMod;
|
||||
|
@ -354,5 +354,17 @@ function patchFactories(factories: Record<string, (module: any, exports: any, re
|
|||
|
||||
if (!patch.all) patches.splice(i--, 1);
|
||||
}
|
||||
|
||||
if (IS_DEV) {
|
||||
if (mod !== originalMod) {
|
||||
factory.$$vencordPatchedSource = String(mod);
|
||||
} else if (wreq != null) {
|
||||
const existingFactory = wreq.m[id];
|
||||
|
||||
if (existingFactory != null) {
|
||||
factory.$$vencordPatchedSource = existingFactory.$$vencordPatchedSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,15 +38,15 @@ export let cache: WebpackInstance["c"];
|
|||
|
||||
export type FilterFn = (mod: any) => boolean;
|
||||
|
||||
type PropsFilter = Array<string>;
|
||||
type CodeFilter = Array<string | RegExp>;
|
||||
type StoreNameFilter = string;
|
||||
export type PropsFilter = Array<string>;
|
||||
export type CodeFilter = Array<string | RegExp>;
|
||||
export type StoreNameFilter = string;
|
||||
|
||||
const stringMatches = (s: string, filter: CodeFilter) =>
|
||||
export const stringMatches = (s: string, filter: CodeFilter) =>
|
||||
filter.every(f =>
|
||||
typeof f === "string"
|
||||
? s.includes(f)
|
||||
: f.test(s)
|
||||
: (f.global && (f.lastIndex = 0), f.test(s))
|
||||
);
|
||||
|
||||
export const filters = {
|
||||
|
@ -258,6 +258,8 @@ export const findBulk = traceFunction("findBulk", function findBulk(...filterFns
|
|||
* @returns string or null
|
||||
*/
|
||||
export const findModuleId = traceFunction("findModuleId", function findModuleId(...code: CodeFilter) {
|
||||
code = code.map(canonicalizeMatch);
|
||||
|
||||
for (const id in wreq.m) {
|
||||
if (stringMatches(wreq.m[id].toString(), code)) return id;
|
||||
}
|
||||
|
@ -452,12 +454,9 @@ export function findExportedComponentLazy<T extends object = any>(...props: Prop
|
|||
* })
|
||||
*/
|
||||
export const mapMangledModule = traceFunction("mapMangledModule", function mapMangledModule<S extends string>(code: string | RegExp | CodeFilter, mappers: Record<S, FilterFn>): Record<S, any> {
|
||||
if (!Array.isArray(code)) code = [code];
|
||||
code = code.map(canonicalizeMatch);
|
||||
|
||||
const exports = {} as Record<S, any>;
|
||||
|
||||
const id = findModuleId(...code);
|
||||
const id = findModuleId(...Array.isArray(code) ? code : [code]);
|
||||
if (id === null)
|
||||
return exports;
|
||||
|
||||
|
@ -606,6 +605,8 @@ export function waitFor(filter: string | PropsFilter | FilterFn, callback: Callb
|
|||
* @returns Mapping of found modules
|
||||
*/
|
||||
export function search(...code: CodeFilter) {
|
||||
code = code.map(canonicalizeMatch);
|
||||
|
||||
const results = {} as Record<number, Function>;
|
||||
const factories = wreq.m;
|
||||
|
||||
|
|
Loading…
Reference in a new issue