mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
Merge branch 'Vendicated:main' into main
This commit is contained in:
commit
529fd26aed
164 changed files with 2435 additions and 1863 deletions
|
@ -5,6 +5,7 @@
|
||||||
// @author Vendicated (https://github.com/Vendicated)
|
// @author Vendicated (https://github.com/Vendicated)
|
||||||
// @namespace https://github.com/Vendicated/Vencord
|
// @namespace https://github.com/Vendicated/Vencord
|
||||||
// @supportURL https://github.com/Vendicated/Vencord
|
// @supportURL https://github.com/Vendicated/Vencord
|
||||||
|
// @icon https://raw.githubusercontent.com/Vendicated/Vencord/refs/heads/main/browser/icon.png
|
||||||
// @license GPL-3.0
|
// @license GPL-3.0
|
||||||
// @match *://*.discord.com/*
|
// @match *://*.discord.com/*
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.9.7",
|
"version": "1.10.5",
|
||||||
"description": "The cutest Discord client mod",
|
"description": "The cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
@ -70,6 +70,7 @@
|
||||||
"stylelint": "^16.8.1",
|
"stylelint": "^16.8.1",
|
||||||
"stylelint-config-standard": "^36.0.1",
|
"stylelint-config-standard": "^36.0.1",
|
||||||
"ts-patch": "^3.2.1",
|
"ts-patch": "^3.2.1",
|
||||||
|
"ts-pattern": "^5.3.1",
|
||||||
"tsx": "^4.16.5",
|
"tsx": "^4.16.5",
|
||||||
"type-fest": "^4.23.0",
|
"type-fest": "^4.23.0",
|
||||||
"typescript": "^5.5.4",
|
"typescript": "^5.5.4",
|
||||||
|
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
|
@ -116,6 +116,9 @@ importers:
|
||||||
ts-patch:
|
ts-patch:
|
||||||
specifier: ^3.2.1
|
specifier: ^3.2.1
|
||||||
version: 3.2.1
|
version: 3.2.1
|
||||||
|
ts-pattern:
|
||||||
|
specifier: ^5.3.1
|
||||||
|
version: 5.3.1
|
||||||
tsx:
|
tsx:
|
||||||
specifier: ^4.16.5
|
specifier: ^4.16.5
|
||||||
version: 4.16.5
|
version: 4.16.5
|
||||||
|
@ -2524,6 +2527,9 @@ packages:
|
||||||
resolution: {integrity: sha512-hlR43v+GUIUy8/ZGFP1DquEqPh7PFKQdDMTAmYt671kCCA6AkDQMoeFaFmZ7ObPLYOmpMgyKUqL1C+coFMf30w==}
|
resolution: {integrity: sha512-hlR43v+GUIUy8/ZGFP1DquEqPh7PFKQdDMTAmYt671kCCA6AkDQMoeFaFmZ7ObPLYOmpMgyKUqL1C+coFMf30w==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
ts-pattern@5.3.1:
|
||||||
|
resolution: {integrity: sha512-1RUMKa8jYQdNfmnK4jyzBK3/PS/tnjcZ1CW0v1vWDeYe5RBklc/nquw03MEoB66hVBm4BnlCfmOqDVxHyT1DpA==}
|
||||||
|
|
||||||
tsconfig-paths@3.15.0:
|
tsconfig-paths@3.15.0:
|
||||||
resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==}
|
resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==}
|
||||||
|
|
||||||
|
@ -5158,6 +5164,8 @@ snapshots:
|
||||||
semver: 7.6.3
|
semver: 7.6.3
|
||||||
strip-ansi: 6.0.1
|
strip-ansi: 6.0.1
|
||||||
|
|
||||||
|
ts-pattern@5.3.1: {}
|
||||||
|
|
||||||
tsconfig-paths@3.15.0:
|
tsconfig-paths@3.15.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/json5': 0.0.29
|
'@types/json5': 0.0.29
|
||||||
|
|
|
@ -21,7 +21,7 @@ import esbuild from "esbuild";
|
||||||
import { readdir } from "fs/promises";
|
import { readdir } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
|
||||||
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, watch } from "./common.mjs";
|
import { BUILD_TIMESTAMP, commonOpts, exists, globPlugins, IS_DEV, IS_REPORTER, IS_STANDALONE, IS_UPDATER_DISABLED, resolvePluginName, VERSION, commonRendererPlugins, watch } from "./common.mjs";
|
||||||
|
|
||||||
const defines = {
|
const defines = {
|
||||||
IS_STANDALONE,
|
IS_STANDALONE,
|
||||||
|
@ -131,7 +131,7 @@ await Promise.all([
|
||||||
sourcemap,
|
sourcemap,
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("discordDesktop"),
|
globPlugins("discordDesktop"),
|
||||||
...commonOpts.plugins
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
@ -180,7 +180,7 @@ await Promise.all([
|
||||||
sourcemap,
|
sourcemap,
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("vencordDesktop"),
|
globPlugins("vencordDesktop"),
|
||||||
...commonOpts.plugins
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
define: {
|
define: {
|
||||||
...defines,
|
...defines,
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { appendFile, mkdir, readdir, readFile, rm, writeFile } from "fs/promises
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import Zip from "zip-local";
|
import Zip from "zip-local";
|
||||||
|
|
||||||
import { BUILD_TIMESTAMP, commonOpts, globPlugins, IS_DEV, IS_REPORTER, VERSION } from "./common.mjs";
|
import { BUILD_TIMESTAMP, commonOpts, globPlugins, IS_DEV, IS_REPORTER, VERSION, commonRendererPlugins } from "./common.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {esbuild.BuildOptions}
|
* @type {esbuild.BuildOptions}
|
||||||
|
@ -36,7 +36,7 @@ const commonOptions = {
|
||||||
external: ["~plugins", "~git-hash", "/assets/*"],
|
external: ["~plugins", "~git-hash", "/assets/*"],
|
||||||
plugins: [
|
plugins: [
|
||||||
globPlugins("web"),
|
globPlugins("web"),
|
||||||
...commonOpts.plugins,
|
...commonRendererPlugins
|
||||||
],
|
],
|
||||||
target: ["esnext"],
|
target: ["esnext"],
|
||||||
define: {
|
define: {
|
||||||
|
@ -116,7 +116,12 @@ await Promise.all(
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
);
|
).catch(err => {
|
||||||
|
console.error("Build failed");
|
||||||
|
console.error(err.message);
|
||||||
|
if (!commonOpts.watch)
|
||||||
|
process.exit(1);
|
||||||
|
});;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {(dir: string) => Promise<string[]>}
|
* @type {(dir: string) => Promise<string[]>}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { join, relative } from "path";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
|
|
||||||
import { getPluginTarget } from "../utils.mjs";
|
import { getPluginTarget } from "../utils.mjs";
|
||||||
|
import { builtinModules } from "module";
|
||||||
|
|
||||||
/** @type {import("../../package.json")} */
|
/** @type {import("../../package.json")} */
|
||||||
const PackageJSON = JSON.parse(readFileSync("package.json"));
|
const PackageJSON = JSON.parse(readFileSync("package.json"));
|
||||||
|
@ -292,6 +293,18 @@ export const stylePlugin = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {(filter: RegExp, message: string) => import("esbuild").Plugin}
|
||||||
|
*/
|
||||||
|
export const banImportPlugin = (filter, message) => ({
|
||||||
|
name: "ban-imports",
|
||||||
|
setup: build => {
|
||||||
|
build.onResolve({ filter }, () => {
|
||||||
|
return { errors: [{ text: message }] };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import("esbuild").BuildOptions}
|
* @type {import("esbuild").BuildOptions}
|
||||||
*/
|
*/
|
||||||
|
@ -311,3 +324,16 @@ export const commonOpts = {
|
||||||
// Work around https://github.com/evanw/esbuild/issues/2460
|
// Work around https://github.com/evanw/esbuild/issues/2460
|
||||||
tsconfig: "./scripts/build/tsconfig.esbuild.json"
|
tsconfig: "./scripts/build/tsconfig.esbuild.json"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const escapedBuiltinModules = builtinModules
|
||||||
|
.map(m => m.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
|
||||||
|
.join("|");
|
||||||
|
const builtinModuleRegex = new RegExp(`^(node:)?(${escapedBuiltinModules})$`);
|
||||||
|
|
||||||
|
export const commonRendererPlugins = [
|
||||||
|
banImportPlugin(builtinModuleRegex, "Cannot import node inbuilt modules in browser code. You need to use a native.ts file"),
|
||||||
|
banImportPlugin(/^react$/, "Cannot import from react. React and hooks should be imported from @webpack/common"),
|
||||||
|
banImportPlugin(/^electron(\/.*)?$/, "Cannot import electron in browser code. You need to use a native.ts file"),
|
||||||
|
banImportPlugin(/^ts-pattern$/, "Cannot import from ts-pattern. match and P should be imported from @webpack/common"),
|
||||||
|
...commonOpts.plugins
|
||||||
|
];
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Logger } from "@utils/Logger";
|
||||||
import { makeCodeblock } from "@utils/text";
|
import { makeCodeblock } from "@utils/text";
|
||||||
|
|
||||||
import { sendBotMessage } from "./commandHelpers";
|
import { sendBotMessage } from "./commandHelpers";
|
||||||
|
@ -46,10 +47,10 @@ export let RequiredMessageOption: Option = ReqPlaceholder;
|
||||||
export const _init = function (cmds: Command[]) {
|
export const _init = function (cmds: Command[]) {
|
||||||
try {
|
try {
|
||||||
BUILT_IN = cmds;
|
BUILT_IN = cmds;
|
||||||
OptionalMessageOption = cmds.find(c => c.name === "shrug")!.options![0];
|
OptionalMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "shrug")!.options![0];
|
||||||
RequiredMessageOption = cmds.find(c => c.name === "me")!.options![0];
|
RequiredMessageOption = cmds.find(c => (c.untranslatedName || c.displayName) === "me")!.options![0];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to load CommandsApi");
|
new Logger("CommandsAPI").error("Failed to load CommandsApi", e, " - cmds is", cmds);
|
||||||
}
|
}
|
||||||
return cmds;
|
return cmds;
|
||||||
} as never;
|
} as never;
|
||||||
|
@ -138,6 +139,8 @@ export function registerCommand<C extends Command>(command: C, plugin: string) {
|
||||||
throw new Error(`Command '${command.name}' already exists.`);
|
throw new Error(`Command '${command.name}' already exists.`);
|
||||||
|
|
||||||
command.isVencordCommand = true;
|
command.isVencordCommand = true;
|
||||||
|
command.untranslatedName ??= command.name;
|
||||||
|
command.untranslatedDescription ??= command.description;
|
||||||
command.id ??= `-${BUILT_IN.length + 1}`;
|
command.id ??= `-${BUILT_IN.length + 1}`;
|
||||||
command.applicationId ??= "-1"; // BUILT_IN;
|
command.applicationId ??= "-1"; // BUILT_IN;
|
||||||
command.type ??= ApplicationCommandType.CHAT_INPUT;
|
command.type ??= ApplicationCommandType.CHAT_INPUT;
|
||||||
|
|
|
@ -93,8 +93,10 @@ export interface Command {
|
||||||
isVencordCommand?: boolean;
|
isVencordCommand?: boolean;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
|
untranslatedName?: string;
|
||||||
displayName?: string;
|
displayName?: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
untranslatedDescription?: string;
|
||||||
displayDescription?: string;
|
displayDescription?: string;
|
||||||
|
|
||||||
options?: Option[];
|
options?: Option[];
|
||||||
|
|
|
@ -90,19 +90,20 @@ export function removeGlobalContextMenuPatch(patch: GlobalContextMenuPatchCallba
|
||||||
* A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children
|
* A helper function for finding the children array of a group nested inside a context menu based on the id(s) of its children
|
||||||
* @param id The id of the child. If an array is specified, all ids will be tried
|
* @param id The id of the child. If an array is specified, all ids will be tried
|
||||||
* @param children The context menu children
|
* @param children The context menu children
|
||||||
|
* @param matchSubstring Whether to check if the id is a substring of the child id
|
||||||
*/
|
*/
|
||||||
export function findGroupChildrenByChildId(id: string | string[], children: Array<ReactElement | null>): Array<ReactElement | null> | null {
|
export function findGroupChildrenByChildId(id: string | string[], children: Array<ReactElement | null | undefined>, matchSubstring = false): Array<ReactElement | null | undefined> | null {
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (child == null) continue;
|
if (child == null) continue;
|
||||||
|
|
||||||
if (Array.isArray(child)) {
|
if (Array.isArray(child)) {
|
||||||
const found = findGroupChildrenByChildId(id, child);
|
const found = findGroupChildrenByChildId(id, child, matchSubstring);
|
||||||
if (found !== null) return found;
|
if (found !== null) return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(Array.isArray(id) && id.some(id => child.props?.id === id))
|
(Array.isArray(id) && id.some(id => matchSubstring ? child.props?.id?.includes(id) : child.props?.id === id))
|
||||||
|| child.props?.id === id
|
|| (matchSubstring ? child.props?.id?.includes(id) : child.props?.id === id)
|
||||||
) return children;
|
) return children;
|
||||||
|
|
||||||
let nextChildren = child.props?.children;
|
let nextChildren = child.props?.children;
|
||||||
|
@ -112,7 +113,7 @@ export function findGroupChildrenByChildId(id: string | string[], children: Arra
|
||||||
child.props.children = nextChildren;
|
child.props.children = nextChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = findGroupChildrenByChildId(id, nextChildren);
|
const found = findGroupChildrenByChildId(id, nextChildren, matchSubstring);
|
||||||
if (found !== null) return found;
|
if (found !== null) return found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,10 @@ export function definePluginSettings<
|
||||||
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
||||||
return Settings.plugins[definedSettings.pluginName] as any;
|
return Settings.plugins[definedSettings.pluginName] as any;
|
||||||
},
|
},
|
||||||
|
get plain() {
|
||||||
|
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
||||||
|
return PlainSettings.plugins[definedSettings.pluginName] as any;
|
||||||
|
},
|
||||||
use: settings => useSettings(
|
use: settings => useSettings(
|
||||||
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
||||||
).plugins[definedSettings.pluginName] as any,
|
).plugins[definedSettings.pluginName] as any,
|
||||||
|
|
|
@ -65,8 +65,7 @@ export function LinkIcon({ height = 24, width = 24, className }: IconProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discord's copy icon, as seen in the user popout right of the username when clicking
|
* Discord's copy icon, as seen in the user panel popout on the right of the username and in large code blocks
|
||||||
* your own username in the bottom left user panel
|
|
||||||
*/
|
*/
|
||||||
export function CopyIcon(props: IconProps) {
|
export function CopyIcon(props: IconProps) {
|
||||||
return (
|
return (
|
||||||
|
@ -76,8 +75,9 @@ export function CopyIcon(props: IconProps) {
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
>
|
>
|
||||||
<g fill="currentColor">
|
<g fill="currentColor">
|
||||||
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1z" />
|
<path d="M3 16a1 1 0 0 1-1-1v-5a8 8 0 0 1 8-8h5a1 1 0 0 1 1 1v.5a.5.5 0 0 1-.5.5H10a6 6 0 0 0-6 6v5.5a.5.5 0 0 1-.5.5H3Z" />
|
||||||
<path d="M15 5H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z" />
|
<path d="M6 18a4 4 0 0 0 4 4h8a4 4 0 0 0 4-4v-4h-3a5 5 0 0 1-5-5V6h-4a4 4 0 0 0-4 4v8Z" />
|
||||||
|
<path d="M21.73 12a3 3 0 0 0-.6-.88l-4.25-4.24a3 3 0 0 0-.88-.61V9a3 3 0 0 0 3 3h2.73Z" />
|
||||||
</g>
|
</g>
|
||||||
</Icon>
|
</Icon>
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Margins } from "@utils/margins";
|
||||||
|
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||||
import { OptionType, PluginOptionNumber } from "@utils/types";
|
import { OptionType, PluginOptionNumber } from "@utils/types";
|
||||||
import { Forms, React, TextInput } from "@webpack/common";
|
import { Forms, React, TextInput } from "@webpack/common";
|
||||||
|
|
||||||
|
@ -54,7 +56,8 @@ export function SettingNumericComponent({ option, pluginSettings, definedSetting
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||||
|
<Forms.FormText className={Margins.bottom20} type="description">{option.description}</Forms.FormText>
|
||||||
<TextInput
|
<TextInput
|
||||||
type="number"
|
type="number"
|
||||||
pattern="-?[0-9]+"
|
pattern="-?[0-9]+"
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Margins } from "@utils/margins";
|
||||||
|
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||||
import { PluginOptionSelect } from "@utils/types";
|
import { PluginOptionSelect } from "@utils/types";
|
||||||
import { Forms, React, Select } from "@webpack/common";
|
import { Forms, React, Select } from "@webpack/common";
|
||||||
|
|
||||||
|
@ -44,7 +46,8 @@ export function SettingSelectComponent({ option, pluginSettings, definedSettings
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||||
|
<Forms.FormText className={Margins.bottom16} type="description">{option.description}</Forms.FormText>
|
||||||
<Select
|
<Select
|
||||||
isDisabled={option.disabled?.call(definedSettings) ?? false}
|
isDisabled={option.disabled?.call(definedSettings) ?? false}
|
||||||
options={option.options}
|
options={option.options}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Margins } from "@utils/margins";
|
||||||
|
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||||
import { PluginOptionSlider } from "@utils/types";
|
import { PluginOptionSlider } from "@utils/types";
|
||||||
import { Forms, React, Slider } from "@webpack/common";
|
import { Forms, React, Slider } from "@webpack/common";
|
||||||
|
|
||||||
|
@ -50,7 +52,8 @@ export function SettingSliderComponent({ option, pluginSettings, definedSettings
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||||
|
<Forms.FormText className={Margins.bottom20} type="description">{option.description}</Forms.FormText>
|
||||||
<Slider
|
<Slider
|
||||||
disabled={option.disabled?.call(definedSettings) ?? false}
|
disabled={option.disabled?.call(definedSettings) ?? false}
|
||||||
markers={option.markers}
|
markers={option.markers}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Margins } from "@utils/margins";
|
||||||
|
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||||
import { PluginOptionString } from "@utils/types";
|
import { PluginOptionString } from "@utils/types";
|
||||||
import { Forms, React, TextInput } from "@webpack/common";
|
import { Forms, React, TextInput } from "@webpack/common";
|
||||||
|
|
||||||
|
@ -41,7 +43,8 @@ export function SettingTextComponent({ option, pluginSettings, definedSettings,
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||||
|
<Forms.FormText className={Margins.bottom20} type="description">{option.description}</Forms.FormText>
|
||||||
<TextInput
|
<TextInput
|
||||||
type="text"
|
type="text"
|
||||||
value={state}
|
value={state}
|
||||||
|
|
|
@ -93,7 +93,7 @@ interface PluginCardProps extends React.HTMLProps<HTMLDivElement> {
|
||||||
export function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLeave, isNew }: PluginCardProps) {
|
export function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLeave, isNew }: PluginCardProps) {
|
||||||
const settings = Settings.plugins[plugin.name];
|
const settings = Settings.plugins[plugin.name];
|
||||||
|
|
||||||
const isEnabled = () => settings.enabled ?? false;
|
const isEnabled = () => Vencord.Plugins.isPluginEnabled(plugin.name);
|
||||||
|
|
||||||
function toggleEnabled() {
|
function toggleEnabled() {
|
||||||
const wasEnabled = isEnabled();
|
const wasEnabled = isEnabled();
|
||||||
|
@ -292,10 +292,10 @@ export default function PluginSettings() {
|
||||||
|
|
||||||
if (!pluginFilter(p)) continue;
|
if (!pluginFilter(p)) continue;
|
||||||
|
|
||||||
const isRequired = p.required || depMap[p.name]?.some(d => settings.plugins[d].enabled);
|
const isRequired = p.required || p.isDependency || depMap[p.name]?.some(d => settings.plugins[d].enabled);
|
||||||
|
|
||||||
if (isRequired) {
|
if (isRequired) {
|
||||||
const tooltipText = p.required
|
const tooltipText = p.required || !depMap[p.name]
|
||||||
? "This plugin is required for Vencord to function."
|
? "This plugin is required for Vencord to function."
|
||||||
: makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled));
|
: makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled));
|
||||||
|
|
||||||
|
|
|
@ -382,6 +382,7 @@ function PatchHelper() {
|
||||||
<Forms.FormTitle className={Margins.top20}>Code</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top20}>Code</Forms.FormTitle>
|
||||||
<CodeBlock lang="js" content={code} />
|
<CodeBlock lang="js" content={code} />
|
||||||
<Button onClick={() => Clipboard.copy(code)}>Copy to Clipboard</Button>
|
<Button onClick={() => Clipboard.copy(code)}>Copy to Clipboard</Button>
|
||||||
|
<Button className={Margins.top8} onClick={() => Clipboard.copy("```ts\n" + code + "\n```")}>Copy as Codeblock</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</SettingsTab>
|
</SettingsTab>
|
||||||
|
|
|
@ -25,10 +25,9 @@ import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
||||||
import type { UserThemeHeader } from "@main/themes";
|
import type { UserThemeHeader } from "@main/themes";
|
||||||
import { openInviteModal } from "@utils/discord";
|
import { openInviteModal } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
|
||||||
import { showItemInFolder } from "@utils/native";
|
import { showItemInFolder } from "@utils/native";
|
||||||
import { useAwaiter } from "@utils/react";
|
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 { Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
|
||||||
import type { ComponentType, Ref, SyntheticEvent } from "react";
|
import type { ComponentType, Ref, SyntheticEvent } from "react";
|
||||||
|
|
||||||
|
@ -45,9 +44,7 @@ type FileInput = ComponentType<{
|
||||||
filters?: { name?: string; extensions: string[]; }[];
|
filters?: { name?: string; extensions: string[]; }[];
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
const InviteActions = findByPropsLazy("resolveInvite");
|
|
||||||
const FileInput: FileInput = findLazy(m => m.prototype?.activateUploadDialogue && m.prototype.setRef);
|
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-");
|
const cl = classNameFactory("vc-settings-theme-");
|
||||||
|
|
||||||
|
@ -80,8 +77,16 @@ function Validators({ themeLinks }: { themeLinks: string[]; }) {
|
||||||
<Forms.FormTitle className={Margins.top20} tag="h5">Validator</Forms.FormTitle>
|
<Forms.FormTitle className={Margins.top20} tag="h5">Validator</Forms.FormTitle>
|
||||||
<Forms.FormText>This section will tell you whether your themes can successfully be loaded</Forms.FormText>
|
<Forms.FormText>This section will tell you whether your themes can successfully be loaded</Forms.FormText>
|
||||||
<div>
|
<div>
|
||||||
{themeLinks.map(link => (
|
{themeLinks.map(rawLink => {
|
||||||
<Card style={{
|
const { label, link } = (() => {
|
||||||
|
const match = /^@(light|dark) (.*)/.exec(rawLink);
|
||||||
|
if (!match) return { label: rawLink, link: rawLink };
|
||||||
|
|
||||||
|
const [, mode, link] = match;
|
||||||
|
return { label: `[${mode} mode only] ${link}`, link };
|
||||||
|
})();
|
||||||
|
|
||||||
|
return <Card style={{
|
||||||
padding: ".5em",
|
padding: ".5em",
|
||||||
marginBottom: ".5em",
|
marginBottom: ".5em",
|
||||||
marginTop: ".5em"
|
marginTop: ".5em"
|
||||||
|
@ -89,11 +94,11 @@ function Validators({ themeLinks }: { themeLinks: string[]; }) {
|
||||||
<Forms.FormTitle tag="h5" style={{
|
<Forms.FormTitle tag="h5" style={{
|
||||||
overflowWrap: "break-word"
|
overflowWrap: "break-word"
|
||||||
}}>
|
}}>
|
||||||
{link}
|
{label}
|
||||||
</Forms.FormTitle>
|
</Forms.FormTitle>
|
||||||
<Validator link={link} />
|
<Validator link={link} />
|
||||||
</Card>
|
</Card>;
|
||||||
))}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -299,6 +304,7 @@ function ThemesTab() {
|
||||||
<Card className="vc-settings-card vc-text-selectable">
|
<Card className="vc-settings-card vc-text-selectable">
|
||||||
<Forms.FormTitle tag="h5">Paste links to css files here</Forms.FormTitle>
|
<Forms.FormTitle tag="h5">Paste links to css files here</Forms.FormTitle>
|
||||||
<Forms.FormText>One link per line</Forms.FormText>
|
<Forms.FormText>One link per line</Forms.FormText>
|
||||||
|
<Forms.FormText>You can prefix lines with @light or @dark to toggle them based on your Discord theme</Forms.FormText>
|
||||||
<Forms.FormText>Make sure to use direct links to files (raw or github.io)!</Forms.FormText>
|
<Forms.FormText>Make sure to use direct links to files (raw or github.io)!</Forms.FormText>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
@ -306,7 +312,7 @@ function ThemesTab() {
|
||||||
<TextArea
|
<TextArea
|
||||||
value={themeText}
|
value={themeText}
|
||||||
onChange={setThemeText}
|
onChange={setThemeText}
|
||||||
className={classes(TextAreaProps.textarea, "vc-settings-theme-links")}
|
className={"vc-settings-theme-links"}
|
||||||
placeholder="Theme Links"
|
placeholder="Theme Links"
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
|
|
|
@ -33,6 +33,20 @@
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
border: 1px solid var(--background-modifier-accent);
|
border: 1px solid var(--background-modifier-accent);
|
||||||
max-height: unset;
|
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 {
|
.vc-cloud-settings-sync-grid {
|
||||||
|
|
|
@ -134,7 +134,7 @@ export async function loadLazyChunks() {
|
||||||
const allChunks = [] as number[];
|
const allChunks = [] as number[];
|
||||||
|
|
||||||
// Matches "id" or id:
|
// Matches "id" or id:
|
||||||
for (const currentMatch of wreq!.u.toString().matchAll(/(?:"([\deE]+?)")|(?:([\deE]+?):)/g)) {
|
for (const currentMatch of wreq!.u.toString().matchAll(/(?:"([\deE]+?)"(?![,}]))|(?:([\deE]+?):)/g)) {
|
||||||
const id = currentMatch[1] ?? currentMatch[2];
|
const id = currentMatch[1] ?? currentMatch[2];
|
||||||
if (id == null) continue;
|
if (id == null) continue;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { onceDefined } from "@shared/onceDefined";
|
import { onceDefined } from "@shared/onceDefined";
|
||||||
import electron, { app, BrowserWindowConstructorOptions, Menu } from "electron";
|
import electron, { app, BrowserWindowConstructorOptions, Menu, nativeTheme } from "electron";
|
||||||
import { dirname, join } from "path";
|
import { dirname, join } from "path";
|
||||||
|
|
||||||
import { initIpc } from "./ipcMain";
|
import { initIpc } from "./ipcMain";
|
||||||
|
@ -100,6 +100,19 @@ if (!IS_VANILLA) {
|
||||||
|
|
||||||
super(options);
|
super(options);
|
||||||
initIpc(this);
|
initIpc(this);
|
||||||
|
|
||||||
|
// Workaround for https://github.com/electron/electron/issues/43367. Vesktop also has its own workaround
|
||||||
|
// @TODO: Remove this when the issue is fixed
|
||||||
|
if (IS_DISCORD_DESKTOP) {
|
||||||
|
this.webContents.on("devtools-opened", () => {
|
||||||
|
if (!nativeTheme.shouldUseDarkColors) return;
|
||||||
|
|
||||||
|
nativeTheme.themeSource = "light";
|
||||||
|
setTimeout(() => {
|
||||||
|
nativeTheme.themeSource = "dark";
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else super(options);
|
} else super(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[class*="profileBadges"] {
|
|
||||||
flex: none;
|
|
||||||
}
|
|
|
@ -16,8 +16,6 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "./fixBadgeOverflow.css";
|
|
||||||
|
|
||||||
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
||||||
import DonateButton from "@components/DonateButton";
|
import DonateButton from "@components/DonateButton";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
@ -62,34 +60,6 @@ export default definePlugin({
|
||||||
authors: [Devs.Megu, Devs.Ven, Devs.TheSun],
|
authors: [Devs.Megu, Devs.Ven, Devs.TheSun],
|
||||||
required: true,
|
required: true,
|
||||||
patches: [
|
patches: [
|
||||||
/* Patch the badge list component on user profiles */
|
|
||||||
{
|
|
||||||
find: 'id:"premium",',
|
|
||||||
replacement: [
|
|
||||||
{
|
|
||||||
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
|
|
||||||
replace: "$&$1.unshift(...$self.getBadges(arguments[0]));",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// alt: "", aria-hidden: false, src: originalSrc
|
|
||||||
match: /alt:" ","aria-hidden":!0,src:(?=(\i)\.src)/,
|
|
||||||
// ...badge.props, ..., src: badge.image ?? ...
|
|
||||||
replace: "...$1.props,$& $1.image??"
|
|
||||||
},
|
|
||||||
// replace their component with ours if applicable
|
|
||||||
{
|
|
||||||
match: /(?<=text:(\i)\.description,spacing:12,.{0,50})children:/,
|
|
||||||
replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :"
|
|
||||||
},
|
|
||||||
// conditionally override their onClick with badge.onClick if it exists
|
|
||||||
{
|
|
||||||
match: /href:(\i)\.link/,
|
|
||||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, $1) }),$&"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
|
|
||||||
/* new profiles */
|
|
||||||
{
|
{
|
||||||
find: ".FULL_SIZE]:26",
|
find: ".FULL_SIZE]:26",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -107,7 +77,7 @@ export default definePlugin({
|
||||||
replace: "...$1.props,$& $1.image??"
|
replace: "...$1.props,$& $1.image??"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(?<=text:(\i)\.description,.{0,50})children:/,
|
match: /(?<=text:(\i)\.description,.{0,200})children:/,
|
||||||
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
|
replace: "children:$1.component ? $self.renderBadgeComponent({ ...$1 }) :"
|
||||||
},
|
},
|
||||||
// conditionally override their onClick with badge.onClick if it exists
|
// conditionally override their onClick with badge.onClick if it exists
|
||||||
|
|
24
src/plugins/_api/dynamicImageModalApi.ts
Normal file
24
src/plugins/_api/dynamicImageModalApi.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "DynamicImageModalAPI",
|
||||||
|
authors: [Devs.sadan, Devs.Nuckyz],
|
||||||
|
description: "Allows you to omit either width or height when opening an image modal",
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "SCALE_DOWN:",
|
||||||
|
replacement: {
|
||||||
|
match: /!\(null==(\i)\|\|0===\i\|\|null==(\i)\|\|0===\i\)/,
|
||||||
|
replace: (_, width, height) => `!((null == ${width} || 0 === ${width}) && (null == ${height} || 0 === ${height}))`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
|
@ -34,7 +34,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "Messages.SERVERS,children",
|
find: "Messages.SERVERS,children",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=Messages\.SERVERS,children:).+?default:return null\}\}\)/,
|
match: /(?<=Messages\.SERVERS,children:)\i\.map\(\i\)/,
|
||||||
replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
|
replace: "Vencord.Api.ServerList.renderAll(Vencord.Api.ServerList.ServerListRenderPosition.In).concat($&)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".METRICS,",
|
find: ".METRICS",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /this\._intervalId=/,
|
match: /this\._intervalId=/,
|
||||||
|
|
|
@ -64,7 +64,7 @@ export default definePlugin({
|
||||||
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
|
replace: (_, sectionTypes, commaOrSemi, elements, element) => `${commaOrSemi} $self.addSettings(${elements}, ${element}, ${sectionTypes}) ${commaOrSemi}`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /({(?=.+?function (\i).{0,120}(\i)=\i\.useMemo.{0,30}return \i\.useMemo\(\(\)=>\i\(\3).+?function\(\){return )\2(?=})/,
|
match: /({(?=.+?function (\i).{0,120}(\i)=\i\.useMemo.{0,60}return \i\.useMemo\(\(\)=>\i\(\3).+?function\(\){return )\2(?=})/,
|
||||||
replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})`
|
replace: (_, rest, settingsHook) => `${rest}$self.wrapSettingsHook(${settingsHook})`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -197,7 +197,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
get electronVersion() {
|
get electronVersion() {
|
||||||
return VencordNative.native.getVersions().electron || window.armcord?.electron || null;
|
return VencordNative.native.getVersions().electron || window.legcord?.electron || null;
|
||||||
},
|
},
|
||||||
|
|
||||||
get chromiumVersion() {
|
get chromiumVersion() {
|
||||||
|
|
|
@ -77,7 +77,7 @@ async function generateDebugInfoMessage() {
|
||||||
const client = (() => {
|
const client = (() => {
|
||||||
if (IS_DISCORD_DESKTOP) return `Discord Desktop v${DiscordNative.app.getVersion()}`;
|
if (IS_DISCORD_DESKTOP) return `Discord Desktop v${DiscordNative.app.getVersion()}`;
|
||||||
if (IS_VESKTOP) return `Vesktop v${VesktopNative.app.getVersion()}`;
|
if (IS_VESKTOP) return `Vesktop v${VesktopNative.app.getVersion()}`;
|
||||||
if ("armcord" in window) return `ArmCord v${window.armcord.version}`;
|
if ("legcord" in window) return `Legcord v${window.legcord.version}`;
|
||||||
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const name = typeof unsafeWindow !== "undefined" ? "UserScript" : "Web";
|
const name = typeof unsafeWindow !== "undefined" ? "UserScript" : "Web";
|
||||||
|
@ -142,15 +142,15 @@ export default definePlugin({
|
||||||
required: true,
|
required: true,
|
||||||
description: "Helps us provide support to you",
|
description: "Helps us provide support to you",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
dependencies: ["CommandsAPI", "UserSettingsAPI", "MessageAccessoriesAPI"],
|
dependencies: ["UserSettingsAPI", "MessageAccessoriesAPI"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [{
|
patches: [{
|
||||||
find: ".BEGINNING_DM.format",
|
find: ".BEGINNING_DM.format",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /BEGINNING_DM\.format\(\{.+?\}\),(?=.{0,100}userId:(\i\.getRecipientId\(\)))/,
|
match: /BEGINNING_DM\.format\(\{.+?\}\),(?=.{0,300}(\i)\.isMultiUserDM)/,
|
||||||
replace: "$& $self.ContributorDmWarningCard({ userId: $1 }),"
|
replace: "$& $self.renderContributorDmWarningCard({ channel: $1 }),"
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
@ -235,7 +235,8 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ContributorDmWarningCard: ErrorBoundary.wrap(({ userId }) => {
|
renderContributorDmWarningCard: ErrorBoundary.wrap(({ channel }) => {
|
||||||
|
const userId = channel.getRecipientId();
|
||||||
if (!isPluginDev(userId)) return null;
|
if (!isPluginDev(userId)) return null;
|
||||||
if (RelationshipStore.isFriend(userId) || isPluginDev(UserStore.getCurrentUser()?.id)) return null;
|
if (RelationshipStore.isFriend(userId) || isPluginDev(UserStore.getCurrentUser()?.id)) return null;
|
||||||
|
|
||||||
|
|
7
src/plugins/accountPanelServerProfile/README.md
Normal file
7
src/plugins/accountPanelServerProfile/README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# AccountPanelServerProfile
|
||||||
|
|
||||||
|
Right click your account panel in the bottom left to view your profile in the current server
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
134
src/plugins/accountPanelServerProfile/index.tsx
Normal file
134
src/plugins/accountPanelServerProfile/index.tsx
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
|
import { ContextMenuApi, Menu, useEffect, useRef } from "@webpack/common";
|
||||||
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
|
interface UserProfileProps {
|
||||||
|
popoutProps: Record<string, any>;
|
||||||
|
currentUser: User;
|
||||||
|
originalPopout: () => React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UserProfile = findComponentByCodeLazy("UserProfilePopoutWrapper: user cannot be undefined");
|
||||||
|
const styles = findByPropsLazy("accountProfilePopoutWrapper");
|
||||||
|
|
||||||
|
let openAlternatePopout = false;
|
||||||
|
let accountPanelRef: React.MutableRefObject<Record<PropertyKey, any> | null> = { current: null };
|
||||||
|
|
||||||
|
const AccountPanelContextMenu = ErrorBoundary.wrap(() => {
|
||||||
|
const { prioritizeServerProfile } = settings.use(["prioritizeServerProfile"]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu.Menu
|
||||||
|
navId="vc-ap-server-profile"
|
||||||
|
onClose={ContextMenuApi.closeContextMenu}
|
||||||
|
>
|
||||||
|
<Menu.MenuItem
|
||||||
|
id="vc-ap-view-alternate-popout"
|
||||||
|
label={prioritizeServerProfile ? "View Account Profile" : "View Server Profile"}
|
||||||
|
disabled={getCurrentChannel()?.getGuildId() == null}
|
||||||
|
action={e => {
|
||||||
|
openAlternatePopout = true;
|
||||||
|
accountPanelRef.current?.props.onMouseDown();
|
||||||
|
accountPanelRef.current?.props.onClick(e);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Menu.MenuCheckboxItem
|
||||||
|
id="vc-ap-prioritize-server-profile"
|
||||||
|
label="Prioritize Server Profile"
|
||||||
|
checked={prioritizeServerProfile}
|
||||||
|
action={() => settings.store.prioritizeServerProfile = !prioritizeServerProfile}
|
||||||
|
/>
|
||||||
|
</Menu.Menu>
|
||||||
|
);
|
||||||
|
}, { noop: true });
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
prioritizeServerProfile: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Prioritize Server Profile when left clicking your account panel",
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "AccountPanelServerProfile",
|
||||||
|
description: "Right click your account panel in the bottom left to view your profile in the current server",
|
||||||
|
authors: [Devs.Nuckyz, Devs.relitrix],
|
||||||
|
settings,
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".Messages.ACCOUNT_SPEAKING_WHILE_MUTED",
|
||||||
|
group: true,
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
match: /(?<=\.SIZE_32\)}\);)/,
|
||||||
|
replace: "$self.useAccountPanelRef();"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /(\.AVATAR,children:.+?renderPopout:(\i)=>){(.+?)}(?=,position)(?<=currentUser:(\i).+?)/,
|
||||||
|
replace: (_, rest, popoutProps, originalPopout, currentUser) => `${rest}$self.UserProfile({popoutProps:${popoutProps},currentUser:${currentUser},originalPopout:()=>{${originalPopout}}})`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /\.AVATAR,children:.+?(?=renderPopout:)/,
|
||||||
|
replace: "$&onRequestClose:$self.onPopoutClose,"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /(?<=.avatarWrapper,)/,
|
||||||
|
replace: "ref:$self.accountPanelRef,onContextMenu:$self.openAccountPanelContextMenu,"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
get accountPanelRef() {
|
||||||
|
return accountPanelRef;
|
||||||
|
},
|
||||||
|
|
||||||
|
useAccountPanelRef() {
|
||||||
|
useEffect(() => () => {
|
||||||
|
accountPanelRef.current = null;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (accountPanelRef = useRef(null));
|
||||||
|
},
|
||||||
|
|
||||||
|
openAccountPanelContextMenu(event: React.UIEvent) {
|
||||||
|
ContextMenuApi.openContextMenu(event, AccountPanelContextMenu);
|
||||||
|
},
|
||||||
|
|
||||||
|
onPopoutClose() {
|
||||||
|
openAlternatePopout = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
UserProfile: ErrorBoundary.wrap(({ popoutProps, currentUser, originalPopout }: UserProfileProps) => {
|
||||||
|
if (
|
||||||
|
(settings.store.prioritizeServerProfile && openAlternatePopout) ||
|
||||||
|
(!settings.store.prioritizeServerProfile && !openAlternatePopout)
|
||||||
|
) {
|
||||||
|
return originalPopout();
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentChannel = getCurrentChannel();
|
||||||
|
if (currentChannel?.getGuildId() == null) {
|
||||||
|
return originalPopout();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.accountProfilePopoutWrapper}>
|
||||||
|
<UserProfile {...popoutProps} userId={currentUser.id} guildId={currentChannel.getGuildId()} channelId={currentChannel.id} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}, { noop: true })
|
||||||
|
});
|
3
src/plugins/alwaysExpandRoles/README.md
Normal file
3
src/plugins/alwaysExpandRoles/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Always Expand Roles
|
||||||
|
|
||||||
|
Always expands the role list in profile popouts
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Vencord, a modification for Discord's desktop app
|
* Vencord, a modification for Discord's desktop app
|
||||||
* Copyright (c) 2022 Vendicated and contributors
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,20 +16,22 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { migratePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
|
migratePluginSettings("AlwaysExpandRoles", "ShowAllRoles");
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "TimeBarAllActivities",
|
name: "AlwaysExpandRoles",
|
||||||
description: "Adds the Spotify time bar to all activities if they have start and end timestamps",
|
description: "Always expands the role list in profile popouts",
|
||||||
authors: [Devs.fawn],
|
authors: [Devs.surgedevs],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "}renderTimeBar(",
|
find: 'action:"EXPAND_ROLES"',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /renderTimeBar\((.{1,3})\){.{0,50}?let/,
|
match: /(roles:\i(?=.+?(\i)\(!0\)[,;]\i\({action:"EXPAND_ROLES"}\)).+?\[\i,\2\]=\i\.useState\()!1\)/,
|
||||||
replace: "renderTimeBar($1){let"
|
replace: (_, rest, setExpandedRoles) => `${rest}!0)`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
});
|
});
|
|
@ -71,7 +71,7 @@ export default definePlugin({
|
||||||
description: "Anonymise uploaded file names",
|
description: "Anonymise uploaded file names",
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "instantBatchUpload:function",
|
find: "instantBatchUpload:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /uploadFiles:(\i),/,
|
match: /uploadFiles:(\i),/,
|
||||||
replace:
|
replace:
|
||||||
|
|
|
@ -24,7 +24,7 @@ interface ActivityButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Activity {
|
interface Activity {
|
||||||
state: string;
|
state?: string;
|
||||||
details?: string;
|
details?: string;
|
||||||
timestamps?: {
|
timestamps?: {
|
||||||
start?: number;
|
start?: number;
|
||||||
|
@ -52,8 +52,8 @@ const enum ActivityFlag {
|
||||||
|
|
||||||
export interface TrackData {
|
export interface TrackData {
|
||||||
name: string;
|
name: string;
|
||||||
album: string;
|
album?: string;
|
||||||
artist: string;
|
artist?: string;
|
||||||
|
|
||||||
appleMusicLink?: string;
|
appleMusicLink?: string;
|
||||||
songLink?: string;
|
songLink?: string;
|
||||||
|
@ -61,8 +61,8 @@ export interface TrackData {
|
||||||
albumArtwork?: string;
|
albumArtwork?: string;
|
||||||
artistArtwork?: string;
|
artistArtwork?: string;
|
||||||
|
|
||||||
playerPosition: number;
|
playerPosition?: number;
|
||||||
duration: number;
|
duration?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enum AssetImageType {
|
const enum AssetImageType {
|
||||||
|
@ -120,7 +120,7 @@ const settings = definePluginSettings({
|
||||||
stateString: {
|
stateString: {
|
||||||
type: OptionType.STRING,
|
type: OptionType.STRING,
|
||||||
description: "Activity state format string",
|
description: "Activity state format string",
|
||||||
default: "{artist}"
|
default: "{artist} · {album}"
|
||||||
},
|
},
|
||||||
largeImageType: {
|
largeImageType: {
|
||||||
type: OptionType.SELECT,
|
type: OptionType.SELECT,
|
||||||
|
@ -155,8 +155,8 @@ const settings = definePluginSettings({
|
||||||
function customFormat(formatStr: string, data: TrackData) {
|
function customFormat(formatStr: string, data: TrackData) {
|
||||||
return formatStr
|
return formatStr
|
||||||
.replaceAll("{name}", data.name)
|
.replaceAll("{name}", data.name)
|
||||||
.replaceAll("{album}", data.album)
|
.replaceAll("{album}", data.album ?? "")
|
||||||
.replaceAll("{artist}", data.artist);
|
.replaceAll("{artist}", data.artist ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageAsset(type: AssetImageType, data: TrackData) {
|
function getImageAsset(type: AssetImageType, data: TrackData) {
|
||||||
|
@ -212,14 +212,16 @@ export default definePlugin({
|
||||||
|
|
||||||
const assets: ActivityAssets = {};
|
const assets: ActivityAssets = {};
|
||||||
|
|
||||||
|
const isRadio = Number.isNaN(trackData.duration) && (trackData.playerPosition === 0);
|
||||||
|
|
||||||
if (settings.store.largeImageType !== AssetImageType.Disabled) {
|
if (settings.store.largeImageType !== AssetImageType.Disabled) {
|
||||||
assets.large_image = largeImageAsset;
|
assets.large_image = largeImageAsset;
|
||||||
assets.large_text = customFormat(settings.store.largeTextString, trackData);
|
if (!isRadio) assets.large_text = customFormat(settings.store.largeTextString, trackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.store.smallImageType !== AssetImageType.Disabled) {
|
if (settings.store.smallImageType !== AssetImageType.Disabled) {
|
||||||
assets.small_image = smallImageAsset;
|
assets.small_image = smallImageAsset;
|
||||||
assets.small_text = customFormat(settings.store.smallTextString, trackData);
|
if (!isRadio) assets.small_text = customFormat(settings.store.smallTextString, trackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buttons: ActivityButton[] = [];
|
const buttons: ActivityButton[] = [];
|
||||||
|
@ -243,17 +245,17 @@ export default definePlugin({
|
||||||
|
|
||||||
name: customFormat(settings.store.nameString, trackData),
|
name: customFormat(settings.store.nameString, trackData),
|
||||||
details: customFormat(settings.store.detailsString, trackData),
|
details: customFormat(settings.store.detailsString, trackData),
|
||||||
state: customFormat(settings.store.stateString, trackData),
|
state: isRadio ? undefined : customFormat(settings.store.stateString, trackData),
|
||||||
|
|
||||||
timestamps: (settings.store.enableTimestamps ? {
|
timestamps: (trackData.playerPosition && trackData.duration && settings.store.enableTimestamps) ? {
|
||||||
start: Date.now() - (trackData.playerPosition * 1000),
|
start: Date.now() - (trackData.playerPosition * 1000),
|
||||||
end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000),
|
end: Date.now() - (trackData.playerPosition * 1000) + (trackData.duration * 1000),
|
||||||
} : undefined),
|
} : undefined,
|
||||||
|
|
||||||
assets,
|
assets,
|
||||||
|
|
||||||
buttons: buttons.length ? buttons.map(v => v.label) : undefined,
|
buttons: !isRadio && buttons.length ? buttons.map(v => v.label) : undefined,
|
||||||
metadata: { button_urls: buttons.map(v => v.url) || undefined, },
|
metadata: !isRadio && buttons.length ? { button_urls: buttons.map(v => v.url) } : undefined,
|
||||||
|
|
||||||
type: settings.store.activityType,
|
type: settings.store.activityType,
|
||||||
flags: ActivityFlag.INSTANCE,
|
flags: ActivityFlag.INSTANCE,
|
||||||
|
|
|
@ -11,37 +11,11 @@ import type { TrackData } from ".";
|
||||||
|
|
||||||
const exec = promisify(execFile);
|
const exec = promisify(execFile);
|
||||||
|
|
||||||
// function exec(file: string, args: string[] = []) {
|
|
||||||
// return new Promise<{ code: number | null, stdout: string | null, stderr: string | null; }>((resolve, reject) => {
|
|
||||||
// const process = spawn(file, args, { stdio: [null, "pipe", "pipe"] });
|
|
||||||
|
|
||||||
// let stdout: string | null = null;
|
|
||||||
// process.stdout.on("data", (chunk: string) => { stdout ??= ""; stdout += chunk; });
|
|
||||||
// let stderr: string | null = null;
|
|
||||||
// process.stderr.on("data", (chunk: string) => { stdout ??= ""; stderr += chunk; });
|
|
||||||
|
|
||||||
// process.on("exit", code => { resolve({ code, stdout, stderr }); });
|
|
||||||
// process.on("error", err => reject(err));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
async function applescript(cmds: string[]) {
|
async function applescript(cmds: string[]) {
|
||||||
const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat());
|
const { stdout } = await exec("osascript", cmds.map(c => ["-e", c]).flat());
|
||||||
return stdout;
|
return stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeSearchUrl(type: string, query: string) {
|
|
||||||
const url = new URL("https://tools.applemediaservices.com/api/apple-media/music/US/search.json");
|
|
||||||
url.searchParams.set("types", type);
|
|
||||||
url.searchParams.set("limit", "1");
|
|
||||||
url.searchParams.set("term", query);
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
const requestOptions: RequestInit = {
|
|
||||||
headers: { "user-agent": "Mozilla/5.0 (Windows NT 10.0; rv:125.0) Gecko/20100101 Firefox/125.0" },
|
|
||||||
};
|
|
||||||
|
|
||||||
interface RemoteData {
|
interface RemoteData {
|
||||||
appleMusicLink?: string,
|
appleMusicLink?: string,
|
||||||
songLink?: string,
|
songLink?: string,
|
||||||
|
@ -51,6 +25,24 @@ interface RemoteData {
|
||||||
|
|
||||||
let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null;
|
let cachedRemoteData: { id: string, data: RemoteData; } | { id: string, failures: number; } | null = null;
|
||||||
|
|
||||||
|
const APPLE_MUSIC_BUNDLE_REGEX = /<script type="module" crossorigin src="([a-zA-Z0-9.\-/]+)"><\/script>/;
|
||||||
|
const APPLE_MUSIC_TOKEN_REGEX = /\w+="([A-Za-z0-9-_]*\.[A-Za-z0-9-_]*\.[A-Za-z0-9-_]*)",\w+="x-apple-jingle-correlation-key"/;
|
||||||
|
|
||||||
|
let cachedToken: string | undefined = undefined;
|
||||||
|
|
||||||
|
const getToken = async () => {
|
||||||
|
if (cachedToken) return cachedToken;
|
||||||
|
|
||||||
|
const html = await fetch("https://music.apple.com/").then(r => r.text());
|
||||||
|
const bundleUrl = new URL(html.match(APPLE_MUSIC_BUNDLE_REGEX)![1], "https://music.apple.com/");
|
||||||
|
|
||||||
|
const bundle = await fetch(bundleUrl).then(r => r.text());
|
||||||
|
const token = bundle.match(APPLE_MUSIC_TOKEN_REGEX)![1];
|
||||||
|
|
||||||
|
cachedToken = token;
|
||||||
|
return token;
|
||||||
|
};
|
||||||
|
|
||||||
async function fetchRemoteData({ id, name, artist, album }: { id: string, name: string, artist: string, album: string; }) {
|
async function fetchRemoteData({ id, name, artist, album }: { id: string, name: string, artist: string, album: string; }) {
|
||||||
if (id === cachedRemoteData?.id) {
|
if (id === cachedRemoteData?.id) {
|
||||||
if ("data" in cachedRemoteData) return cachedRemoteData.data;
|
if ("data" in cachedRemoteData) return cachedRemoteData.data;
|
||||||
|
@ -58,21 +50,39 @@ async function fetchRemoteData({ id, name, artist, album }: { id: string, name:
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [songData, artistData] = await Promise.all([
|
const dataUrl = new URL("https://amp-api-edge.music.apple.com/v1/catalog/us/search");
|
||||||
fetch(makeSearchUrl("songs", artist + " " + album + " " + name), requestOptions).then(r => r.json()),
|
dataUrl.searchParams.set("platform", "web");
|
||||||
fetch(makeSearchUrl("artists", artist.split(/ *[,&] */)[0]), requestOptions).then(r => r.json())
|
dataUrl.searchParams.set("l", "en-US");
|
||||||
]);
|
dataUrl.searchParams.set("limit", "1");
|
||||||
|
dataUrl.searchParams.set("with", "serverBubbles");
|
||||||
|
dataUrl.searchParams.set("types", "songs");
|
||||||
|
dataUrl.searchParams.set("term", `${name} ${artist} ${album}`);
|
||||||
|
dataUrl.searchParams.set("include[songs]", "artists");
|
||||||
|
|
||||||
const appleMusicLink = songData?.songs?.data[0]?.attributes.url;
|
const token = await getToken();
|
||||||
const songLink = songData?.songs?.data[0]?.id ? `https://song.link/i/${songData?.songs?.data[0]?.id}` : undefined;
|
|
||||||
|
|
||||||
const albumArtwork = songData?.songs?.data[0]?.attributes.artwork.url.replace("{w}", "512").replace("{h}", "512");
|
const songData = await fetch(dataUrl, {
|
||||||
const artistArtwork = artistData?.artists?.data[0]?.attributes.artwork.url.replace("{w}", "512").replace("{h}", "512");
|
headers: {
|
||||||
|
"accept": "*/*",
|
||||||
|
"accept-language": "en-US,en;q=0.9",
|
||||||
|
"authorization": `Bearer ${token}`,
|
||||||
|
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||||
|
"origin": "https://music.apple.com",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => data.results.song.data[0]);
|
||||||
|
|
||||||
cachedRemoteData = {
|
cachedRemoteData = {
|
||||||
id,
|
id,
|
||||||
data: { appleMusicLink, songLink, albumArtwork, artistArtwork }
|
data: {
|
||||||
|
appleMusicLink: songData.attributes.url,
|
||||||
|
songLink: `https://song.link/i/${songData.id}`,
|
||||||
|
albumArtwork: songData.attributes.artwork.url.replace("{w}x{h}", "512x512"),
|
||||||
|
artistArtwork: songData.relationships.artists.data[0].attributes.artwork.url.replace("{w}x{h}", "512x512"),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return cachedRemoteData.data;
|
return cachedRemoteData.data;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("[AppleMusicRichPresence] Failed to fetch remote data:", e);
|
console.error("[AppleMusicRichPresence] Failed to fetch remote data:", e);
|
||||||
|
|
|
@ -73,8 +73,8 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
// ArmCord comes with its own arRPC implementation, so this plugin just confuses users
|
// Legcord comes with its own arRPC implementation, so this plugin just confuses users
|
||||||
if ("armcord" in window) return;
|
if ("legcord" in window) return;
|
||||||
|
|
||||||
if (ws) ws.close();
|
if (ws) ws.close();
|
||||||
ws = new WebSocket("ws://127.0.0.1:1337"); // try to open WebSocket
|
ws = new WebSocket("ws://127.0.0.1:1337"); // try to open WebSocket
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# AutomodContext
|
|
||||||
|
|
||||||
Allows you to jump to the messages surrounding an automod hit
|
|
||||||
|
|
||||||

|
|
|
@ -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 })
|
|
||||||
});
|
|
11
src/plugins/betterFolders/README.md
Normal file
11
src/plugins/betterFolders/README.md
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Better Folders
|
||||||
|
|
||||||
|
Better Folders offers a variety of options to improve your folder experience
|
||||||
|
|
||||||
|
Always show the folder icon, regardless of if the folder is open or not
|
||||||
|
|
||||||
|
Only have one folder open at a time
|
||||||
|
|
||||||
|
Open folders in a sidebar:
|
||||||
|
|
||||||
|

|
|
@ -30,9 +30,9 @@ enum FolderIconDisplay {
|
||||||
MoreThanOneFolderExpanded
|
MoreThanOneFolderExpanded
|
||||||
}
|
}
|
||||||
|
|
||||||
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
|
|
||||||
const SortedGuildStore = findStoreLazy("SortedGuildStore");
|
|
||||||
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
|
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
|
||||||
|
const SortedGuildStore = findStoreLazy("SortedGuildStore");
|
||||||
|
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
|
||||||
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
|
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
|
||||||
|
|
||||||
let lastGuildId = null as string | null;
|
let lastGuildId = null as string | null;
|
||||||
|
@ -118,22 +118,22 @@ export default definePlugin({
|
||||||
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
|
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
|
||||||
{
|
{
|
||||||
match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
|
match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
|
||||||
replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)`
|
replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0]?.isBetterFolders,betterFoldersOriginalTree,arguments[0]?.betterFoldersExpandedIds)`
|
||||||
},
|
},
|
||||||
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
|
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
|
||||||
{
|
{
|
||||||
match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/,
|
match: /lastTargetNode:\i\[\i\.length-1\].+?Fragment.+?\]}\)\]/,
|
||||||
replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0].isBetterFolders))"
|
replace: "$&.filter($self.makeGuildsBarGuildListFilter(!!arguments[0]?.isBetterFolders))"
|
||||||
},
|
},
|
||||||
// If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children
|
// If we are rendering the Better Folders sidebar, we filter out everything but the scroller for the guild list from the GuildsBar Tree children
|
||||||
{
|
{
|
||||||
match: /unreadMentionsIndicatorBottom,.+?}\)\]/,
|
match: /unreadMentionsIndicatorBottom,.+?}\)\]/,
|
||||||
replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0].isBetterFolders))"
|
replace: "$&.filter($self.makeGuildsBarTreeFilter(!!arguments[0]?.isBetterFolders))"
|
||||||
},
|
},
|
||||||
// Export the isBetterFolders variable to the folders component
|
// Export the isBetterFolders variable to the folders component
|
||||||
{
|
{
|
||||||
match: /(?<=\.Messages\.SERVERS.+?switch\((\i)\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,)/,
|
match: /switch\(\i\.type\){case \i\.\i\.FOLDER:.+?folderNode:\i,/,
|
||||||
replace: 'isBetterFolders:typeof isBetterFolders!=="undefined"?isBetterFolders:false,'
|
replace: '$&isBetterFolders:typeof isBetterFolders!=="undefined"?isBetterFolders:false,'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -167,31 +167,31 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
predicate: () => settings.store.keepIcons,
|
predicate: () => settings.store.keepIcons,
|
||||||
match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/,
|
match: /(?<=let{folderNode:\i,setNodeRef:\i,.+?expanded:(\i),.+?;)(?=let)/,
|
||||||
replace: (_, isExpanded) => `${isExpanded}=!!arguments[0].isBetterFolders&&${isExpanded};`
|
replace: (_, isExpanded) => `${isExpanded}=!!arguments[0]?.isBetterFolders&&${isExpanded};`
|
||||||
},
|
},
|
||||||
// Disable expanding and collapsing folders transition in the normal GuildsBar sidebar
|
// Disable expanding and collapsing folders transition in the normal GuildsBar sidebar
|
||||||
{
|
{
|
||||||
predicate: () => !settings.store.keepIcons,
|
predicate: () => !settings.store.keepIcons,
|
||||||
match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/,
|
match: /(?<=\.Messages\.SERVER_FOLDER_PLACEHOLDER.+?useTransition\)\()/,
|
||||||
replace: "!!arguments[0].isBetterFolders&&"
|
replace: "$self.shouldShowTransition(arguments[0])&&"
|
||||||
},
|
},
|
||||||
// If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded
|
// If we are rendering the normal GuildsBar sidebar, we avoid rendering guilds from folders that are expanded
|
||||||
{
|
{
|
||||||
predicate: () => !settings.store.keepIcons,
|
predicate: () => !settings.store.keepIcons,
|
||||||
match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/,
|
match: /expandedFolderBackground,.+?,(?=\i\(\(\i,\i,\i\)=>{let{key.{0,45}ul)(?<=selected:\i,expanded:(\i),.+?)/,
|
||||||
replace: (m, isExpanded) => `${m}!arguments[0].isBetterFolders&&${isExpanded}?null:`
|
replace: (m, isExpanded) => `${m}$self.shouldRenderContents(arguments[0],${isExpanded})?null:`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar
|
// Decide if we should render the expanded folder background if we are rendering the Better Folders sidebar
|
||||||
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
||||||
match: /(?<=\.wrapper,children:\[)/,
|
match: /(?<=\.wrapper,children:\[)/,
|
||||||
replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)&&"
|
replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar
|
// Decide if we should render the expanded folder icon if we are rendering the Better Folders sidebar
|
||||||
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
predicate: () => settings.store.showFolderIcon !== FolderIconDisplay.Always,
|
||||||
match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/,
|
match: /(?<=\.expandedFolderBackground.+?}\),)(?=\i,)/,
|
||||||
replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0].isBetterFolders,arguments[0].betterFoldersExpandedIds)?null:"
|
replace: "!$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)?null:"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -200,8 +200,8 @@ export default definePlugin({
|
||||||
predicate: () => settings.store.sidebar,
|
predicate: () => settings.store.sidebar,
|
||||||
replacement: {
|
replacement: {
|
||||||
// Render the Better Folders sidebar
|
// Render the Better Folders sidebar
|
||||||
match: /(?<=({className:\i\.guilds,themeOverride:\i})\))/,
|
match: /(container.{0,50}({className:\i\.guilds,themeOverride:\i})\))/,
|
||||||
replace: ",$self.FolderSideBar($1)"
|
replace: "$1,$self.FolderSideBar({...$2})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -306,7 +306,20 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
FolderSideBar: guildsBarProps => <FolderSideBar {...guildsBarProps} />,
|
shouldShowTransition(props: any) {
|
||||||
|
// Pending guilds
|
||||||
|
if (props?.folderNode?.id === 1) return true;
|
||||||
|
|
||||||
closeFolders
|
return !!props?.isBetterFolders;
|
||||||
|
},
|
||||||
|
|
||||||
|
shouldRenderContents(props: any, isExpanded: boolean) {
|
||||||
|
// Pending guilds
|
||||||
|
if (props?.folderNode?.id === 1) return false;
|
||||||
|
|
||||||
|
return !props?.isBetterFolders && isExpanded;
|
||||||
|
},
|
||||||
|
|
||||||
|
FolderSideBar,
|
||||||
|
closeFolders,
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,13 +17,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { canonicalizeMatch } from "@utils/patches";
|
import { canonicalizeMatch } from "@utils/patches";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
|
||||||
|
|
||||||
const UserPopoutSectionCssClasses = findByPropsLazy("section", "lastSection");
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
hide: {
|
hide: {
|
||||||
|
@ -72,23 +68,9 @@ export default definePlugin({
|
||||||
match: /\.NOTE_PLACEHOLDER,/,
|
match: /\.NOTE_PLACEHOLDER,/,
|
||||||
replace: "$&spellCheck:!$self.noSpellCheck,"
|
replace: "$&spellCheck:!$self.noSpellCheck,"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
find: ".popularApplicationCommandIds,",
|
|
||||||
replacement: {
|
|
||||||
match: /lastSection:(!?\i)}\),/,
|
|
||||||
replace: "$&$self.patchPadding({lastSection:$1}),"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
patchPadding: ErrorBoundary.wrap(({ lastSection }) => {
|
|
||||||
if (!lastSection) return null;
|
|
||||||
return (
|
|
||||||
<div className={UserPopoutSectionCssClasses.lastSection} ></div>
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
|
|
||||||
get noSpellCheck() {
|
get noSpellCheck() {
|
||||||
return settings.store.noSpellCheck;
|
return settings.store.noSpellCheck;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,11 @@ export default definePlugin({
|
||||||
id="vc-view-role-icon"
|
id="vc-view-role-icon"
|
||||||
label="View Role Icon"
|
label="View Role Icon"
|
||||||
action={() => {
|
action={() => {
|
||||||
openImageModal(`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${role.id}/${role.icon}.${settings.store.roleIconFileFormat}`);
|
openImageModal({
|
||||||
|
url: `${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${role.id}/${role.icon}.${settings.store.roleIconFileFormat}`,
|
||||||
|
height: 128,
|
||||||
|
width: 128
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon={ImageIcon}
|
icon={ImageIcon}
|
||||||
/>
|
/>
|
||||||
|
|
68
src/plugins/betterSettings/PluginsSubmenu.tsx
Normal file
68
src/plugins/betterSettings/PluginsSubmenu.tsx
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
||||||
|
import { isObjectEmpty } from "@utils/misc";
|
||||||
|
import { Alerts, i18n, Menu, useMemo, useState } from "@webpack/common";
|
||||||
|
|
||||||
|
import Plugins from "~plugins";
|
||||||
|
|
||||||
|
function onRestartNeeded() {
|
||||||
|
Alerts.show({
|
||||||
|
title: "Restart required",
|
||||||
|
body: <p>You have changed settings that require a restart.</p>,
|
||||||
|
confirmText: "Restart now",
|
||||||
|
cancelText: "Later!",
|
||||||
|
onConfirm: () => location.reload()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PluginsSubmenu() {
|
||||||
|
const sortedPlugins = useMemo(() => Object.values(Plugins)
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name)), []);
|
||||||
|
const [query, setQuery] = useState("");
|
||||||
|
|
||||||
|
const search = query.toLowerCase();
|
||||||
|
const include = (p: typeof Plugins[keyof typeof Plugins]) => (
|
||||||
|
Vencord.Plugins.isPluginEnabled(p.name)
|
||||||
|
&& p.options && !isObjectEmpty(p.options)
|
||||||
|
&& (
|
||||||
|
p.name.toLowerCase().includes(search)
|
||||||
|
|| p.description.toLowerCase().includes(search)
|
||||||
|
|| p.tags?.some(t => t.toLowerCase().includes(search))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const plugins = sortedPlugins.filter(include);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Menu.MenuControlItem
|
||||||
|
id="vc-plugins-search"
|
||||||
|
control={(props, ref) => (
|
||||||
|
<Menu.MenuSearchControl
|
||||||
|
{...props}
|
||||||
|
query={query}
|
||||||
|
onChange={setQuery}
|
||||||
|
ref={ref}
|
||||||
|
placeholder={i18n.Messages.SEARCH}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{!!plugins.length && <Menu.MenuSeparator />}
|
||||||
|
|
||||||
|
{plugins.map(p => (
|
||||||
|
<Menu.MenuItem
|
||||||
|
key={p.name}
|
||||||
|
id={p.name}
|
||||||
|
label={p.name}
|
||||||
|
action={() => openPluginModal(p, onRestartNeeded)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -13,6 +13,8 @@ import { waitFor } from "@webpack";
|
||||||
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
|
import { ComponentDispatch, FocusLock, i18n, Menu, useEffect, useRef } from "@webpack/common";
|
||||||
import type { HTMLAttributes, ReactElement } from "react";
|
import type { HTMLAttributes, ReactElement } from "react";
|
||||||
|
|
||||||
|
import PluginsSubmenu from "./PluginsSubmenu";
|
||||||
|
|
||||||
type SettingsEntry = { section: string, label: string; };
|
type SettingsEntry = { section: string, label: string; };
|
||||||
|
|
||||||
const cl = classNameFactory("");
|
const cl = classNameFactory("");
|
||||||
|
@ -118,13 +120,21 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{ // Settings cog context menu
|
{ // Settings cog context menu
|
||||||
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /(EXPERIMENTS:.+?)(\(0,\i.\i\)\(\))(?=\.filter\(\i=>\{let\{section:\i\}=)/,
|
{
|
||||||
replace: "$1$self.wrapMenu($2)"
|
match: /(EXPERIMENTS:.+?)(\(0,\i.\i\)\(\))(?=\.filter\(\i=>\{let\{section:\i\}=)/,
|
||||||
}
|
replace: "$1$self.wrapMenu($2)"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
match: /case \i\.\i\.DEVELOPER_OPTIONS:return \i;/,
|
||||||
|
replace: "$&case 'VencordPlugins':return $self.PluginsSubmenu();"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
PluginsSubmenu,
|
||||||
|
|
||||||
// This is the very outer layer of the entire ui, so we can't wrap this in an ErrorBoundary
|
// This is the very outer layer of the entire ui, so we can't wrap this in an ErrorBoundary
|
||||||
// without possibly also catching unrelated errors of children.
|
// without possibly also catching unrelated errors of children.
|
||||||
//
|
//
|
||||||
|
|
|
@ -57,7 +57,11 @@ export const handleViewPreview = async ({ guildId, channelId, ownerId }: Applica
|
||||||
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);
|
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);
|
||||||
if (!previewUrl) return;
|
if (!previewUrl) return;
|
||||||
|
|
||||||
openImageModal(previewUrl);
|
openImageModal({
|
||||||
|
url: previewUrl,
|
||||||
|
height: 720,
|
||||||
|
width: 1280
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {
|
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {
|
||||||
|
|
|
@ -45,8 +45,8 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: ".embedWrapper,embed",
|
find: ".embedWrapper,embed",
|
||||||
replacement: [{
|
replacement: [{
|
||||||
match: /\.embedWrapper(?=.+?channel_id:(\i)\.id)/g,
|
match: /\.container/,
|
||||||
replace: "$&+($1.nsfw?' vc-nsfw-img':'')"
|
replace: "$&+(this.props.channel.nsfw? ' vc-nsfw-img': '')"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -155,4 +155,5 @@ export const defaultRules = [
|
||||||
"igshid",
|
"igshid",
|
||||||
"igsh",
|
"igsh",
|
||||||
"share_id@reddit.com",
|
"share_id@reddit.com",
|
||||||
|
"si@soundcloud.com",
|
||||||
];
|
];
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
import { findByCodeLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByCodeLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||||
import { Button, Forms, useStateFromStores } from "@webpack/common";
|
import { Button, Forms, ThemeStore, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
const ColorPicker = findComponentByCodeLazy(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
|
const ColorPicker = findComponentByCodeLazy(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR", ".BACKGROUND_PRIMARY)");
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ function setTheme(theme: string) {
|
||||||
saveClientTheme({ theme });
|
saveClientTheme({ theme });
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThemeStore = findStoreLazy("ThemeStore");
|
|
||||||
const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore");
|
const NitroThemeStore = findStoreLazy("ClientThemesBackgroundStore");
|
||||||
|
|
||||||
function ThemeSettings() {
|
function ThemeSettings() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# ConsoleJanitor
|
# ConsoleJanitor
|
||||||
|
|
||||||
Disables annoying console messages/errors. This plugin mainly removes errors/warnings that happen all the time and noisy/spammy logging messages.
|
Disables annoying console messages/errors. This plugin mainly removes errors/warnings that happen all the time and Discord logger messages.
|
||||||
|
|
||||||
Some of the disabled messages include the "notosans-400-normalitalic" error and MessageActionCreators, Routing/Utils loggers.
|
One of the disabled messages is the "Window state not initialized" warning, for example.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType, StartAt } from "@utils/types";
|
||||||
|
|
||||||
const Noop = () => { };
|
const Noop = () => { };
|
||||||
const NoopLogger = {
|
const NoopLogger = {
|
||||||
|
@ -22,10 +22,12 @@ const NoopLogger = {
|
||||||
fileOnly: Noop
|
fileOnly: Noop
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logAllow = new Set();
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
disableNoisyLoggers: {
|
disableLoggers: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Disable noisy loggers like the MessageActionCreators",
|
description: "Disables Discords loggers",
|
||||||
default: false,
|
default: false,
|
||||||
restartNeeded: true
|
restartNeeded: true
|
||||||
},
|
},
|
||||||
|
@ -34,18 +36,43 @@ const settings = definePluginSettings({
|
||||||
description: "Disable the Spotify logger, which leaks account information and access token",
|
description: "Disable the Spotify logger, which leaks account information and access token",
|
||||||
default: true,
|
default: true,
|
||||||
restartNeeded: true
|
restartNeeded: true
|
||||||
|
},
|
||||||
|
whitelistedLoggers: {
|
||||||
|
type: OptionType.STRING,
|
||||||
|
description: "Semi colon separated list of loggers to allow even if others are hidden",
|
||||||
|
default: "GatewaySocket; Routing/Utils",
|
||||||
|
onChange(newVal: string) {
|
||||||
|
logAllow.clear();
|
||||||
|
newVal.split(";").map(x => x.trim()).forEach(logAllow.add.bind(logAllow));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ConsoleJanitor",
|
name: "ConsoleJanitor",
|
||||||
description: "Disables annoying console messages/errors",
|
description: "Disables annoying console messages/errors",
|
||||||
authors: [Devs.Nuckyz],
|
authors: [Devs.Nuckyz, Devs.sadan],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
startAt: StartAt.Init,
|
||||||
|
start() {
|
||||||
|
logAllow.clear();
|
||||||
|
this.settings.store.whitelistedLoggers?.split(";").map(x => x.trim()).forEach(logAllow.add.bind(logAllow));
|
||||||
|
},
|
||||||
|
|
||||||
NoopLogger: () => NoopLogger,
|
NoopLogger: () => NoopLogger,
|
||||||
|
shouldLog(logger: string) {
|
||||||
|
return logAllow.has(logger);
|
||||||
|
},
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
|
{
|
||||||
|
find: 'react-spring: The "interpolate" function',
|
||||||
|
replacement: {
|
||||||
|
match: /,console.warn\('react-spring: The "interpolate" function is deprecated in v10 \(use "to" instead\)'\)/,
|
||||||
|
replace: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
find: 'console.warn("Window state not initialized"',
|
find: 'console.warn("Window state not initialized"',
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -60,13 +87,6 @@ export default definePlugin({
|
||||||
replace: ""
|
replace: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
find: "notosans-400-normalitalic",
|
|
||||||
replacement: {
|
|
||||||
match: /,"notosans-.+?"/g,
|
|
||||||
replace: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");',
|
find: 'console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");',
|
||||||
all: true,
|
all: true,
|
||||||
|
@ -110,34 +130,13 @@ export default definePlugin({
|
||||||
replace: ""
|
replace: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...[
|
// Patches discords generic logger function
|
||||||
'("MessageActionCreators")', '("ChannelMessages")',
|
|
||||||
'("Routing/Utils")', '("RTCControlSocket")',
|
|
||||||
'("ConnectionEventFramerateReducer")', '("RTCLatencyTestManager")',
|
|
||||||
'("OverlayBridgeStore")', '("RPCServer:WSS")', '("RPCServer:IPC")'
|
|
||||||
].map(logger => ({
|
|
||||||
find: logger,
|
|
||||||
predicate: () => settings.store.disableNoisyLoggers,
|
|
||||||
all: true,
|
|
||||||
replacement: {
|
|
||||||
match: new RegExp(String.raw`new \i\.\i${logger.replace(/([()])/g, "\\$1")}`),
|
|
||||||
replace: `$self.NoopLogger${logger}`
|
|
||||||
}
|
|
||||||
})),
|
|
||||||
{
|
{
|
||||||
find: '"Experimental codecs: "',
|
find: "Σ:",
|
||||||
predicate: () => settings.store.disableNoisyLoggers,
|
predicate: () => settings.store.disableLoggers,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /new \i\.\i\("Connection\("\.concat\(\i,"\)"\)\)/,
|
match: /(?<=&&)(?=console)/,
|
||||||
replace: "$self.NoopLogger()"
|
replace: "$self.shouldLog(arguments[0])&&"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: '"Handling ping: "',
|
|
||||||
predicate: () => settings.store.disableNoisyLoggers,
|
|
||||||
replacement: {
|
|
||||||
match: /new \i\.\i\("RTCConnection\("\.concat.+?\)\)(?=,)/,
|
|
||||||
replace: "$self.NoopLogger()"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -148,5 +147,5 @@ export default definePlugin({
|
||||||
replace: "$self.NoopLogger()"
|
replace: "$self.NoopLogger()"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
5
src/plugins/copyFileContents/README.md
Normal file
5
src/plugins/copyFileContents/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# CopyFileContents
|
||||||
|
|
||||||
|
Adds a button to text file attachments to copy their contents.
|
||||||
|
|
||||||
|

|
60
src/plugins/copyFileContents/index.tsx
Normal file
60
src/plugins/copyFileContents/index.tsx
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import "./style.css";
|
||||||
|
|
||||||
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { CopyIcon, NoEntrySignIcon } from "@components/Icons";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { copyWithToast } from "@utils/misc";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { Tooltip, useState } from "@webpack/common";
|
||||||
|
|
||||||
|
const CheckMarkIcon = () => {
|
||||||
|
return <svg width="24" height="24" viewBox="0 0 24 24">
|
||||||
|
<path fill="currentColor" d="M21.7 5.3a1 1 0 0 1 0 1.4l-12 12a1 1 0 0 1-1.4 0l-6-6a1 1 0 1 1 1.4-1.4L9 16.58l11.3-11.3a1 1 0 0 1 1.4 0Z"></path>
|
||||||
|
</svg>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "CopyFileContents",
|
||||||
|
description: "Adds a button to text file attachments to copy their contents",
|
||||||
|
authors: [Devs.Obsidian, Devs.Nuckyz],
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".Messages.PREVIEW_BYTES_LEFT.format(",
|
||||||
|
replacement: {
|
||||||
|
match: /\.footerGap.+?url:\i,fileName:\i,fileSize:\i}\),(?<=fileContents:(\i),bytesLeft:(\i).+?)/g,
|
||||||
|
replace: "$&$self.addCopyButton({fileContents:$1,bytesLeft:$2}),"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
addCopyButton: ErrorBoundary.wrap(({ fileContents, bytesLeft }: { fileContents: string, bytesLeft: number; }) => {
|
||||||
|
const [recentlyCopied, setRecentlyCopied] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip text={recentlyCopied ? "Copied!" : bytesLeft > 0 ? "File too large to copy" : "Copy File Contents"}>
|
||||||
|
{tooltipProps => (
|
||||||
|
<div
|
||||||
|
{...tooltipProps}
|
||||||
|
className="vc-cfc-button"
|
||||||
|
role="button"
|
||||||
|
onClick={() => {
|
||||||
|
if (!recentlyCopied && bytesLeft <= 0) {
|
||||||
|
copyWithToast(fileContents);
|
||||||
|
setRecentlyCopied(true);
|
||||||
|
setTimeout(() => setRecentlyCopied(false), 2000);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{recentlyCopied ? <CheckMarkIcon /> : bytesLeft > 0 ? <NoEntrySignIcon color="var(--channel-icon)" /> : <CopyIcon />}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}, { noop: true }),
|
||||||
|
});
|
9
src/plugins/copyFileContents/style.css
Normal file
9
src/plugins/copyFileContents/style.css
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.vc-cfc-button {
|
||||||
|
color: var(--interactive-normal);
|
||||||
|
cursor: pointer;
|
||||||
|
padding-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-cfc-button:hover {
|
||||||
|
color: var(--interactive-hover);
|
||||||
|
}
|
|
@ -175,7 +175,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
if (settings.store.attemptToNavigateToHome) {
|
if (settings.store.attemptToNavigateToHome) {
|
||||||
try {
|
try {
|
||||||
NavigationRouter.transitionTo("/channels/@me");
|
NavigationRouter.transitionToGuild("@me");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
CrashHandlerLogger.debug("Failed to navigate to home", err);
|
CrashHandlerLogger.debug("Failed to navigate to home", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,11 @@ import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByCodeLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common";
|
import { ApplicationAssetUtils, Button, FluxDispatcher, Forms, GuildStore, React, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color");
|
const useProfileThemeStyle = findByCodeLazy("profileThemeStyle:", "--profile-gradient-primary-color");
|
||||||
const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile");
|
const ActivityComponent = findComponentByCodeLazy("onOpenGameProfile");
|
||||||
const ActivityClassName = findByPropsLazy("activity", "buttonColor");
|
|
||||||
|
|
||||||
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
const ShowCurrentGame = getUserSettingLazy<boolean>("status", "showCurrentGame")!;
|
||||||
|
|
||||||
|
@ -436,8 +435,8 @@ export default definePlugin({
|
||||||
|
|
||||||
<Forms.FormDivider className={Margins.top8} />
|
<Forms.FormDivider className={Margins.top8} />
|
||||||
|
|
||||||
<div style={{ width: "284px", ...profileThemeStyle }}>
|
<div style={{ width: "284px", ...profileThemeStyle, padding: 8, marginTop: 8, borderRadius: 8, background: "var(--bg-mod-faint)" }}>
|
||||||
{activity[0] && <ActivityComponent activity={activity[0]} className={ActivityClassName.activity} channelId={SelectedChannelStore.getChannelId()}
|
{activity[0] && <ActivityComponent activity={activity[0]} channelId={SelectedChannelStore.getChannelId()}
|
||||||
guild={GuildStore.getGuild(SelectedGuildStore.getLastSelectedGuildId())}
|
guild={GuildStore.getGuild(SelectedGuildStore.getLastSelectedGuildId())}
|
||||||
application={{ id: settings.store.appID }}
|
application={{ id: settings.store.appID }}
|
||||||
user={UserStore.getCurrentUser()} />}
|
user={UserStore.getCurrentUser()} />}
|
||||||
|
|
|
@ -37,8 +37,8 @@ export default definePlugin({
|
||||||
find: 'type:"IDLE",idle:',
|
find: 'type:"IDLE",idle:',
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /(?<=Date\.now\(\)-\i>)\i\.\i/,
|
match: /(?<=Date\.now\(\)-\i>)\i\.\i\|\|/,
|
||||||
replace: "$self.getIdleTimeout()"
|
replace: "$self.getIdleTimeout()||"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /Math\.min\((\i\.\i\.getSetting\(\)\*\i\.\i\.\i\.SECOND),\i\.\i\)/,
|
match: /Math\.min\((\i\.\i\.getSetting\(\)\*\i\.\i\.\i\.SECOND),\i\.\i\)/,
|
||||||
|
|
|
@ -46,7 +46,7 @@ const embedUrlRe = /https:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]{11})/;
|
||||||
async function embedDidMount(this: Component<Props>) {
|
async function embedDidMount(this: Component<Props>) {
|
||||||
try {
|
try {
|
||||||
const { embed } = this.props;
|
const { embed } = this.props;
|
||||||
const { replaceElements } = settings.store;
|
const { replaceElements, dearrowByDefault } = settings.store;
|
||||||
|
|
||||||
if (!embed || embed.dearrow || embed.provider?.name !== "YouTube" || !embed.video?.url) return;
|
if (!embed || embed.dearrow || embed.provider?.name !== "YouTube" || !embed.video?.url) return;
|
||||||
|
|
||||||
|
@ -63,18 +63,22 @@ async function embedDidMount(this: Component<Props>) {
|
||||||
|
|
||||||
if (!hasTitle && !hasThumb) return;
|
if (!hasTitle && !hasThumb) return;
|
||||||
|
|
||||||
|
|
||||||
embed.dearrow = {
|
embed.dearrow = {
|
||||||
enabled: true
|
enabled: dearrowByDefault
|
||||||
};
|
};
|
||||||
|
|
||||||
if (hasTitle && replaceElements !== ReplaceElements.ReplaceThumbnailsOnly) {
|
if (hasTitle && replaceElements !== ReplaceElements.ReplaceThumbnailsOnly) {
|
||||||
embed.dearrow.oldTitle = embed.rawTitle;
|
const replacementTitle = titles[0].title.replace(/(^|\s)>(\S)/g, "$1$2");
|
||||||
embed.rawTitle = titles[0].title.replace(/(^|\s)>(\S)/g, "$1$2");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
embed.dearrow.oldTitle = dearrowByDefault ? embed.rawTitle : replacementTitle;
|
||||||
|
if (dearrowByDefault) embed.rawTitle = replacementTitle;
|
||||||
|
}
|
||||||
if (hasThumb && replaceElements !== ReplaceElements.ReplaceTitlesOnly) {
|
if (hasThumb && replaceElements !== ReplaceElements.ReplaceTitlesOnly) {
|
||||||
embed.dearrow.oldThumb = embed.thumbnail.proxyURL;
|
const replacementProxyURL = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${videoId}&time=${thumbnails[0].timestamp}`;
|
||||||
embed.thumbnail.proxyURL = `https://dearrow-thumb.ajay.app/api/v1/getThumbnail?videoID=${videoId}&time=${thumbnails[0].timestamp}`;
|
|
||||||
|
embed.dearrow.oldThumb = dearrowByDefault ? embed.thumbnail.proxyURL : replacementProxyURL;
|
||||||
|
if (dearrowByDefault) embed.thumbnail.proxyURL = replacementProxyURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
|
@ -96,6 +100,7 @@ function DearrowButton({ component }: { component: Component<Props>; }) {
|
||||||
className={"vc-dearrow-toggle-" + (embed.dearrow.enabled ? "on" : "off")}
|
className={"vc-dearrow-toggle-" + (embed.dearrow.enabled ? "on" : "off")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const { enabled, oldThumb, oldTitle } = embed.dearrow;
|
const { enabled, oldThumb, oldTitle } = embed.dearrow;
|
||||||
|
settings.store.dearrowByDefault = !enabled;
|
||||||
embed.dearrow.enabled = !enabled;
|
embed.dearrow.enabled = !enabled;
|
||||||
if (oldTitle) {
|
if (oldTitle) {
|
||||||
embed.dearrow.oldTitle = embed.rawTitle;
|
embed.dearrow.oldTitle = embed.rawTitle;
|
||||||
|
@ -153,6 +158,12 @@ const settings = definePluginSettings({
|
||||||
{ label: "Titles", value: ReplaceElements.ReplaceTitlesOnly },
|
{ label: "Titles", value: ReplaceElements.ReplaceTitlesOnly },
|
||||||
{ label: "Thumbnails", value: ReplaceElements.ReplaceThumbnailsOnly },
|
{ label: "Thumbnails", value: ReplaceElements.ReplaceThumbnailsOnly },
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
dearrowByDefault: {
|
||||||
|
description: "Dearrow videos automatically",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: true,
|
||||||
|
restartNeeded: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default definePlugin({
|
||||||
replace: "$self.DecorationGridItem=$&"
|
replace: "$self.DecorationGridItem=$&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /(?<==)\i=>{let{user:\i,avatarDecoration.{300,600}decorationGridItemChurned/,
|
match: /(?<==)\i=>{let{user:\i,avatarDecoration/,
|
||||||
replace: "$self.DecorationGridDecoration=$&"
|
replace: "$self.DecorationGridDecoration=$&"
|
||||||
},
|
},
|
||||||
// Remove NEW label from decor avatar decorations
|
// Remove NEW label from decor avatar decorations
|
||||||
|
@ -91,7 +91,7 @@ export default definePlugin({
|
||||||
replacement: [
|
replacement: [
|
||||||
// Use Decor avatar decoration hook
|
// Use Decor avatar decoration hook
|
||||||
{
|
{
|
||||||
match: /(?<=\i\)\({avatarDecoration:)(\i).avatarDecoration(?=,)/,
|
match: /(?<=\i\)\({avatarDecoration:)(\i)(?=,)(?<=currentUser:(\i).+?)/,
|
||||||
replace: "$self.useUserDecorAvatarDecoration($1)??$&"
|
replace: "$self.useUserDecorAvatarDecoration($1)??$&"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -23,12 +23,13 @@ import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy, findLazy } from "@webpack";
|
||||||
import { Forms, React } from "@webpack/common";
|
import { Forms, React } from "@webpack/common";
|
||||||
|
|
||||||
import hideBugReport from "./hideBugReport.css?managed";
|
import hideBugReport from "./hideBugReport.css?managed";
|
||||||
|
|
||||||
const KbdStyles = findByPropsLazy("key", "combo");
|
const KbdStyles = findByPropsLazy("key", "combo");
|
||||||
|
const BugReporterExperiment = findLazy(m => m?.definition?.id === "2024-09_bug_reporter");
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
toolbarDevMenu: {
|
toolbarDevMenu: {
|
||||||
|
@ -78,8 +79,8 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "toolbar:function",
|
find: "toolbar:function",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\i\.isStaff\(\)/,
|
match: /hasBugReporterAccess:(\i)/,
|
||||||
replace: "true"
|
replace: "_hasBugReporterAccess:$1=true"
|
||||||
},
|
},
|
||||||
predicate: () => settings.store.toolbarDevMenu
|
predicate: () => settings.store.toolbarDevMenu
|
||||||
},
|
},
|
||||||
|
@ -91,10 +92,18 @@ export default definePlugin({
|
||||||
match: /\i\.isDM\(\)\|\|\i\.isThread\(\)/,
|
match: /\i\.isDM\(\)\|\|\i\.isThread\(\)/,
|
||||||
replace: "false",
|
replace: "false",
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// enable option to always record clips even if you are not streaming
|
||||||
|
{
|
||||||
|
find: "isDecoupledGameClippingEnabled(){",
|
||||||
|
replacement: {
|
||||||
|
match: /\i\.isStaff\(\)/,
|
||||||
|
replace: "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
start: () => enableStyle(hideBugReport),
|
start: () => !BugReporterExperiment.getCurrentConfig().hasBugReporterAccess && enableStyle(hideBugReport),
|
||||||
stop: () => disableStyle(hideBugReport),
|
stop: () => disableStyle(hideBugReport),
|
||||||
|
|
||||||
settingsAboutComponent: () => {
|
settingsAboutComponent: () => {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { ApngBlendOp, ApngDisposeOp, importApngJs } from "@utils/dependencies";
|
import { ApngBlendOp, ApngDisposeOp, importApngJs } from "@utils/dependencies";
|
||||||
import { getCurrentGuild } from "@utils/discord";
|
import { getCurrentGuild } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType, Patch } from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy, findStoreLazy, proxyLazyWebpack } from "@webpack";
|
||||||
import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
import { Alerts, ChannelStore, DraftType, EmojiStore, FluxDispatcher, Forms, GuildMemberStore, IconUtils, lodash, Parser, PermissionsBits, PermissionStore, UploadHandler, UserSettingsActionCreators, UserStore } from "@webpack/common";
|
||||||
import type { Emoji } from "@webpack/types";
|
import type { Emoji } from "@webpack/types";
|
||||||
|
@ -194,6 +194,26 @@ const hasExternalStickerPerms = (channelId: string) => hasPermission(channelId,
|
||||||
const hasEmbedPerms = (channelId: string) => hasPermission(channelId, PermissionsBits.EMBED_LINKS);
|
const hasEmbedPerms = (channelId: string) => hasPermission(channelId, PermissionsBits.EMBED_LINKS);
|
||||||
const hasAttachmentPerms = (channelId: string) => hasPermission(channelId, PermissionsBits.ATTACH_FILES);
|
const hasAttachmentPerms = (channelId: string) => hasPermission(channelId, PermissionsBits.ATTACH_FILES);
|
||||||
|
|
||||||
|
function makeBypassPatches(): Omit<Patch, "plugin"> {
|
||||||
|
const mapping: Array<{ func: string, predicate?: () => boolean; }> = [
|
||||||
|
{ func: "canUseCustomStickersEverywhere", predicate: () => settings.store.enableStickerBypass },
|
||||||
|
{ func: "canUseHighVideoUploadQuality", predicate: () => settings.store.enableStreamQualityBypass },
|
||||||
|
{ func: "canStreamQuality", predicate: () => settings.store.enableStreamQualityBypass },
|
||||||
|
{ func: "canUseClientThemes" },
|
||||||
|
{ func: "canUseCustomNotificationSounds" },
|
||||||
|
{ func: "canUsePremiumAppIcons" }
|
||||||
|
];
|
||||||
|
|
||||||
|
return {
|
||||||
|
find: "canUseCustomStickersEverywhere:",
|
||||||
|
replacement: mapping.map(({ func, predicate }) => ({
|
||||||
|
match: new RegExp(String.raw`(?<=${func}:function\(\i(?:,\i)?\){)`),
|
||||||
|
replace: "return true;",
|
||||||
|
predicate
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FakeNitro",
|
name: "FakeNitro",
|
||||||
authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.fawn, Devs.captain, Devs.Nuckyz, Devs.AutumnVN],
|
authors: [Devs.Arjix, Devs.D3SOX, Devs.Ven, Devs.fawn, Devs.captain, Devs.Nuckyz, Devs.AutumnVN],
|
||||||
|
@ -203,6 +223,17 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
|
// General bypass patches
|
||||||
|
makeBypassPatches(),
|
||||||
|
// Patch the emoji picker in voice calls to not be bypassed by fake nitro
|
||||||
|
{
|
||||||
|
find: "emojiItemDisabled]",
|
||||||
|
predicate: () => settings.store.enableEmojiBypass,
|
||||||
|
replacement: {
|
||||||
|
match: /CHAT/,
|
||||||
|
replace: "STATUS"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
find: ".PREMIUM_LOCKED;",
|
find: ".PREMIUM_LOCKED;",
|
||||||
group: true,
|
group: true,
|
||||||
|
@ -243,15 +274,6 @@ export default definePlugin({
|
||||||
replace: (_, rest1, rest2) => `${rest1},fakeNitroOriginal){if(!fakeNitroOriginal)return false;${rest2}`
|
replace: (_, rest1, rest2) => `${rest1},fakeNitroOriginal){if(!fakeNitroOriginal)return false;${rest2}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Allow stickers to be sent everywhere
|
|
||||||
{
|
|
||||||
find: "canUseCustomStickersEverywhere:function",
|
|
||||||
predicate: () => settings.store.enableStickerBypass,
|
|
||||||
replacement: {
|
|
||||||
match: /canUseCustomStickersEverywhere:function\(\i\){/,
|
|
||||||
replace: "$&return true;"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// Make stickers always available
|
// Make stickers always available
|
||||||
{
|
{
|
||||||
find: '"SENDABLE"',
|
find: '"SENDABLE"',
|
||||||
|
@ -261,20 +283,6 @@ export default definePlugin({
|
||||||
replace: "true?"
|
replace: "true?"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Allow streaming with high quality
|
|
||||||
{
|
|
||||||
find: "canUseHighVideoUploadQuality:function",
|
|
||||||
predicate: () => settings.store.enableStreamQualityBypass,
|
|
||||||
replacement: [
|
|
||||||
"canUseHighVideoUploadQuality",
|
|
||||||
"canStreamQuality",
|
|
||||||
].map(func => {
|
|
||||||
return {
|
|
||||||
match: new RegExp(`${func}:function\\(\\i(?:,\\i)?\\){`, "g"),
|
|
||||||
replace: "$&return true;"
|
|
||||||
};
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// Remove boost requirements to stream with high quality
|
// Remove boost requirements to stream with high quality
|
||||||
{
|
{
|
||||||
find: "STREAM_FPS_OPTION.format",
|
find: "STREAM_FPS_OPTION.format",
|
||||||
|
@ -284,14 +292,6 @@ export default definePlugin({
|
||||||
replace: ""
|
replace: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Allow client themes to be changeable
|
|
||||||
{
|
|
||||||
find: "canUseClientThemes:function",
|
|
||||||
replacement: {
|
|
||||||
match: /canUseClientThemes:function\(\i\){/,
|
|
||||||
replace: "$&return true;"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: '"UserSettingsProtoStore"',
|
find: '"UserSettingsProtoStore"',
|
||||||
replacement: [
|
replacement: [
|
||||||
|
@ -350,7 +350,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
// Filter attachments to remove fake nitro stickers or emojis
|
// Filter attachments to remove fake nitro stickers or emojis
|
||||||
predicate: () => settings.store.transformStickers,
|
predicate: () => settings.store.transformStickers,
|
||||||
match: /renderAttachments\(\i\){let{attachments:(\i).+?;/,
|
match: /renderAttachments\(\i\){.+?{attachments:(\i).+?;/,
|
||||||
replace: (m, attachments) => `${m}${attachments}=$self.filterAttachments(${attachments});`
|
replace: (m, attachments) => `${m}${attachments}=$self.filterAttachments(${attachments});`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -389,14 +389,6 @@ export default definePlugin({
|
||||||
replace: (_, reactNode, props) => `$self.addFakeNotice(${FakeNoticeType.Emoji},${reactNode},!!${props}?.fakeNitroNode?.fake)`
|
replace: (_, reactNode, props) => `$self.addFakeNotice(${FakeNoticeType.Emoji},${reactNode},!!${props}?.fakeNitroNode?.fake)`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Allow using custom app icons
|
|
||||||
{
|
|
||||||
find: "canUsePremiumAppIcons:function",
|
|
||||||
replacement: {
|
|
||||||
match: /canUsePremiumAppIcons:function\(\i\){/,
|
|
||||||
replace: "$&return true;"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Separate patch for allowing using custom app icons
|
// Separate patch for allowing using custom app icons
|
||||||
{
|
{
|
||||||
find: /\.getCurrentDesktopIcon.{0,25}\.isPremium/,
|
find: /\.getCurrentDesktopIcon.{0,25}\.isPremium/,
|
||||||
|
@ -412,14 +404,6 @@ export default definePlugin({
|
||||||
match: /(?<=type:"(?:SOUNDBOARD_SOUNDS_RECEIVED|GUILD_SOUNDBOARD_SOUND_CREATE|GUILD_SOUNDBOARD_SOUND_UPDATE|GUILD_SOUNDBOARD_SOUNDS_UPDATE)".+?available:)\i\.available/g,
|
match: /(?<=type:"(?:SOUNDBOARD_SOUNDS_RECEIVED|GUILD_SOUNDBOARD_SOUND_CREATE|GUILD_SOUNDBOARD_SOUND_UPDATE|GUILD_SOUNDBOARD_SOUNDS_UPDATE)".+?available:)\i\.available/g,
|
||||||
replace: "true"
|
replace: "true"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
// Allow using custom notification sounds
|
|
||||||
{
|
|
||||||
find: "canUseCustomNotificationSounds:function",
|
|
||||||
replacement: {
|
|
||||||
match: /canUseCustomNotificationSounds:function\(\i\){/,
|
|
||||||
replace: "$&return true;"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "UserProfileStore",
|
find: "UserProfileStore",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=getUserProfile\(\i\){return )(\i\[\i\])/,
|
match: /(?<=getUserProfile\(\i\){return )(.+?)(?=})/,
|
||||||
replace: "$self.colorDecodeHook($1)"
|
replace: "$self.colorDecodeHook($1)"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
3
src/plugins/fixImagesQuality/README.md
Normal file
3
src/plugins/fixImagesQuality/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Fix Images Quality
|
||||||
|
|
||||||
|
Prevents images from being loaded as webp, which can cause quality loss
|
|
@ -8,16 +8,15 @@ import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoDefaultHangStatus",
|
name: "FixImagesQuality",
|
||||||
description: "Disable the default hang status when joining voice channels",
|
description: "Prevents images from being loaded as webp, which can cause quality loss",
|
||||||
authors: [Devs.D3SOX],
|
authors: [Devs.Nuckyz],
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: ".CHILLING)",
|
find: "getFormatQuality(){",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /{enableHangStatus:(\i),/,
|
match: /(?<=null;return )\i\.\i&&\(\i\|\|!\i\.isAnimated.+?:(?=\i&&\(\i="png"\))/,
|
||||||
replace: "{_enableHangStatus:$1=false,"
|
replace: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -27,7 +27,6 @@ export default definePlugin({
|
||||||
name: "FriendInvites",
|
name: "FriendInvites",
|
||||||
description: "Create and manage friend invite links via slash commands (/create friend invite, /view friend invites, /revoke friend invites).",
|
description: "Create and manage friend invite links via slash commands (/create friend invite, /view friend invites, /revoke friend invites).",
|
||||||
authors: [Devs.afn, Devs.Dziurwa],
|
authors: [Devs.afn, Devs.Dziurwa],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
name: "create friend invite",
|
name: "create friend invite",
|
||||||
|
|
|
@ -7,121 +7,47 @@
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import { Logger } from "@utils/Logger";
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByCodeLazy, findByPropsLazy, findLazy } from "@webpack";
|
import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Heading, RelationshipStore, Text } from "@webpack/common";
|
import { RelationshipStore, Text } from "@webpack/common";
|
||||||
|
|
||||||
const containerWrapper = findByPropsLazy("memberSinceWrapper");
|
const containerWrapper = findByPropsLazy("memberSinceWrapper");
|
||||||
const container = findByPropsLazy("memberSince");
|
const container = findByPropsLazy("memberSince");
|
||||||
const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"');
|
const getCreatedAtDate = findByCodeLazy('month:"short",day:"numeric"');
|
||||||
const locale = findByPropsLazy("getLocale");
|
const locale = findByPropsLazy("getLocale");
|
||||||
const lastSection = findByPropsLazy("lastSection");
|
const Section = findComponentByCodeLazy('"auto":"smooth"', ".section");
|
||||||
const section = findLazy((m: any) => m.section !== void 0 && m.heading !== void 0 && Object.values(m).length === 2);
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "FriendsSince",
|
name: "FriendsSince",
|
||||||
description: "Shows when you became friends with someone in the user popout",
|
description: "Shows when you became friends with someone in the user popout",
|
||||||
authors: [Devs.Elvyra, Devs.Antti],
|
authors: [Devs.Elvyra, Devs.Antti],
|
||||||
patches: [
|
patches: [
|
||||||
// User popup - old layout
|
// DM User Sidebar
|
||||||
{
|
|
||||||
find: ".USER_PROFILE}};return",
|
|
||||||
replacement: {
|
|
||||||
match: /,{userId:(\i.id).{0,30}}\)/,
|
|
||||||
replace: "$&,$self.friendsSinceOld({ userId: $1 })"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// DM User Sidebar - old layout
|
|
||||||
{
|
|
||||||
find: ".PROFILE_PANEL,",
|
|
||||||
replacement: {
|
|
||||||
match: /,{userId:([^,]+?)}\)/,
|
|
||||||
replace: "$&,$self.friendsSinceOld({ userId: $1 })"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// User Profile Modal - old layout
|
|
||||||
{
|
|
||||||
find: ".userInfoSectionHeader,",
|
|
||||||
replacement: {
|
|
||||||
match: /(\.Messages\.USER_PROFILE_MEMBER_SINCE.+?userId:(.+?),textClassName:)(\i\.userInfoText)}\)/,
|
|
||||||
replace: (_, rest, userId, textClassName) => `${rest}!$self.getFriendSince(${userId}) ? ${textClassName} : void 0 }), $self.friendsSinceOld({ userId: ${userId}, textClassName: ${textClassName} })`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// DM User Sidebar - new layout
|
|
||||||
{
|
{
|
||||||
find: ".PANEL}),nicknameIcons",
|
find: ".PANEL}),nicknameIcons",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/,
|
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/,
|
||||||
replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})"
|
replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:true})"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// User Profile Modal - new layout
|
// User Profile Modal
|
||||||
{
|
{
|
||||||
find: "action:\"PRESS_APP_CONNECTION\"",
|
find: "action:\"PRESS_APP_CONNECTION\"",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id),.{0,100}}\)}\),/,
|
match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id),.{0,100}}\)}\),/,
|
||||||
replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:false}),"
|
replace: "$&,$self.FriendsSinceComponent({userId:$1,isSidebar:false}),"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
getFriendSince(userId: string) {
|
FriendsSinceComponent: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => {
|
||||||
try {
|
|
||||||
if (!RelationshipStore.isFriend(userId)) return null;
|
|
||||||
|
|
||||||
return RelationshipStore.getSince(userId);
|
|
||||||
} catch (err) {
|
|
||||||
new Logger("FriendsSince").error(err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
friendsSinceOld: ErrorBoundary.wrap(({ userId, textClassName }: { userId: string; textClassName?: string; }) => {
|
|
||||||
if (!RelationshipStore.isFriend(userId)) return null;
|
if (!RelationshipStore.isFriend(userId)) return null;
|
||||||
|
|
||||||
const friendsSince = RelationshipStore.getSince(userId);
|
const friendsSince = RelationshipStore.getSince(userId);
|
||||||
if (!friendsSince) return null;
|
if (!friendsSince) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={lastSection.section}>
|
<Section heading="Friends Since">
|
||||||
<Heading variant="eyebrow">
|
|
||||||
Friends Since
|
|
||||||
</Heading>
|
|
||||||
|
|
||||||
<div className={containerWrapper.memberSinceWrapper}>
|
|
||||||
{!!getCurrentChannel()?.guild_id && (
|
|
||||||
<svg
|
|
||||||
aria-hidden="true"
|
|
||||||
width="16"
|
|
||||||
height="16"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="var(--interactive-normal)"
|
|
||||||
>
|
|
||||||
<path d="M13 10a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z" />
|
|
||||||
<path d="M3 5v-.75C3 3.56 3.56 3 4.25 3s1.24.56 1.33 1.25C6.12 8.65 9.46 12 13 12h1a8 8 0 0 1 8 8 2 2 0 0 1-2 2 .21.21 0 0 1-.2-.15 7.65 7.65 0 0 0-1.32-2.3c-.15-.2-.42-.06-.39.17l.25 2c.02.15-.1.28-.25.28H9a2 2 0 0 1-2-2v-2.22c0-1.57-.67-3.05-1.53-4.37A15.85 15.85 0 0 1 3 5Z" />
|
|
||||||
</svg>
|
|
||||||
)}
|
|
||||||
<Text variant="text-sm/normal" className={textClassName}>
|
|
||||||
{getCreatedAtDate(friendsSince, locale.getLocale())}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}, { noop: true }),
|
|
||||||
|
|
||||||
friendsSinceNew: ErrorBoundary.wrap(({ userId, isSidebar }: { userId: string; isSidebar: boolean; }) => {
|
|
||||||
if (!RelationshipStore.isFriend(userId)) return null;
|
|
||||||
|
|
||||||
const friendsSince = RelationshipStore.getSince(userId);
|
|
||||||
if (!friendsSince) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<section className={section.section}>
|
|
||||||
<Heading variant="text-xs/semibold" style={isSidebar ? {} : { color: "var(--header-secondary)" }}>
|
|
||||||
Friends Since
|
|
||||||
</Heading>
|
|
||||||
|
|
||||||
{
|
{
|
||||||
isSidebar ? (
|
isSidebar ? (
|
||||||
<Text variant="text-sm/normal">
|
<Text variant="text-sm/normal">
|
||||||
|
@ -149,8 +75,7 @@ export default definePlugin({
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
</Section>
|
||||||
</section>
|
|
||||||
);
|
);
|
||||||
}, { noop: true }),
|
}, { noop: true }),
|
||||||
});
|
});
|
||||||
|
|
5
src/plugins/fullSearchContext/README.md
Normal file
5
src/plugins/fullSearchContext/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# FullSearchContext
|
||||||
|
|
||||||
|
Makes the message context menu in message search results have all options you'd expect.
|
||||||
|
|
||||||
|

|
111
src/plugins/fullSearchContext/index.tsx
Normal file
111
src/plugins/fullSearchContext/index.tsx
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
|
import { migratePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { NoopComponent } from "@utils/react";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { filters, findByPropsLazy, waitFor } from "@webpack";
|
||||||
|
import { ChannelStore, ContextMenuApi, i18n, UserStore } from "@webpack/common";
|
||||||
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
const { useMessageMenu } = findByPropsLazy("useMessageMenu");
|
||||||
|
|
||||||
|
interface CopyIdMenuItemProps {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let CopyIdMenuItem: (props: CopyIdMenuItemProps) => React.ReactElement | null = NoopComponent;
|
||||||
|
waitFor(filters.componentByCode('"devmode-copy-id-".concat'), m => CopyIdMenuItem = m);
|
||||||
|
|
||||||
|
function MessageMenu({ message, channel, onHeightUpdate }) {
|
||||||
|
const canReport = message.author &&
|
||||||
|
!(message.author.id === UserStore.getCurrentUser().id || message.author.system);
|
||||||
|
|
||||||
|
return useMessageMenu({
|
||||||
|
navId: "message-actions",
|
||||||
|
ariaLabel: i18n.Messages.MESSAGE_UTILITIES_A11Y_LABEL,
|
||||||
|
|
||||||
|
message,
|
||||||
|
channel,
|
||||||
|
canReport,
|
||||||
|
onHeightUpdate,
|
||||||
|
onClose: () => ContextMenuApi.closeContextMenu(),
|
||||||
|
|
||||||
|
textSelection: "",
|
||||||
|
favoriteableType: null,
|
||||||
|
favoriteableId: null,
|
||||||
|
favoriteableName: null,
|
||||||
|
itemHref: void 0,
|
||||||
|
itemSrc: void 0,
|
||||||
|
itemSafeSrc: void 0,
|
||||||
|
itemTextContent: void 0,
|
||||||
|
|
||||||
|
isFullSearchContextMenu: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MessageActionsProps {
|
||||||
|
message: Message;
|
||||||
|
isFullSearchContextMenu?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const contextMenuPatch: NavContextMenuPatchCallback = (children, props: MessageActionsProps) => {
|
||||||
|
if (props?.isFullSearchContextMenu == null) return;
|
||||||
|
|
||||||
|
const group = findGroupChildrenByChildId("devmode-copy-id", children, true);
|
||||||
|
group?.push(
|
||||||
|
CopyIdMenuItem({ id: props.message.author.id, label: i18n.Messages.COPY_ID_AUTHOR })
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
migratePluginSettings("FullSearchContext", "SearchReply");
|
||||||
|
export default definePlugin({
|
||||||
|
name: "FullSearchContext",
|
||||||
|
description: "Makes the message context menu in message search results have all options you'd expect",
|
||||||
|
authors: [Devs.Ven, Devs.Aria],
|
||||||
|
|
||||||
|
patches: [{
|
||||||
|
find: "onClick:this.handleMessageClick,",
|
||||||
|
replacement: {
|
||||||
|
match: /this(?=\.handleContextMenu\(\i,\i\))/,
|
||||||
|
replace: "$self"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
|
handleContextMenu(event: React.MouseEvent, message: Message) {
|
||||||
|
const channel = ChannelStore.getChannel(message.channel_id);
|
||||||
|
if (!channel) return;
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
ContextMenuApi.openContextMenu(event, contextMenuProps =>
|
||||||
|
<MessageMenu
|
||||||
|
message={message}
|
||||||
|
channel={channel}
|
||||||
|
onHeightUpdate={contextMenuProps.onHeightUpdate}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
contextMenus: {
|
||||||
|
"message-actions": contextMenuPatch
|
||||||
|
}
|
||||||
|
});
|
13
src/plugins/ignoreActivities/README.md
Normal file
13
src/plugins/ignoreActivities/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# IgnoreActivities
|
||||||
|
|
||||||
|
Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The activity stays showing as a detected game even if ignored, differently from the stock Toggle Detection button from Discord:
|
||||||
|
|
||||||
|

|
|
@ -26,6 +26,11 @@ interface IgnoredActivity {
|
||||||
type: ActivitiesTypes;
|
type: ActivitiesTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enum FilterMode {
|
||||||
|
Whitelist,
|
||||||
|
Blacklist
|
||||||
|
}
|
||||||
|
|
||||||
const RunningGameStore = findStoreLazy("RunningGameStore");
|
const RunningGameStore = findStoreLazy("RunningGameStore");
|
||||||
|
|
||||||
const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!;
|
const ShowCurrentGame = getUserSettingLazy("status", "showCurrentGame")!;
|
||||||
|
@ -70,14 +75,17 @@ function handleActivityToggle(e: React.MouseEvent<HTMLButtonElement, MouseEvent>
|
||||||
if (ignoredActivityIndex === -1) settings.store.ignoredActivities = getIgnoredActivities().concat(activity);
|
if (ignoredActivityIndex === -1) settings.store.ignoredActivities = getIgnoredActivities().concat(activity);
|
||||||
else settings.store.ignoredActivities = getIgnoredActivities().filter((_, index) => index !== ignoredActivityIndex);
|
else settings.store.ignoredActivities = getIgnoredActivities().filter((_, index) => index !== ignoredActivityIndex);
|
||||||
|
|
||||||
// Trigger activities recalculation
|
recalculateActivities();
|
||||||
|
}
|
||||||
|
|
||||||
|
function recalculateActivities() {
|
||||||
ShowCurrentGame.updateSetting(old => old);
|
ShowCurrentGame.updateSetting(old => old);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImportCustomRPCComponent() {
|
function ImportCustomRPCComponent() {
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column">
|
<Flex flexDirection="column">
|
||||||
<Forms.FormText type={Forms.FormText.Types.DESCRIPTION}>Import the application id of the CustomRPC plugin to the allowed list</Forms.FormText>
|
<Forms.FormText type={Forms.FormText.Types.DESCRIPTION}>Import the application id of the CustomRPC plugin to the filter list</Forms.FormText>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -86,7 +94,7 @@ function ImportCustomRPCComponent() {
|
||||||
return showToast("CustomRPC application ID is not set.", Toasts.Type.FAILURE);
|
return showToast("CustomRPC application ID is not set.", Toasts.Type.FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isAlreadyAdded = allowedIdsPushID?.(id);
|
const isAlreadyAdded = idsListPushID?.(id);
|
||||||
if (isAlreadyAdded) {
|
if (isAlreadyAdded) {
|
||||||
showToast("CustomRPC application ID is already added.", Toasts.Type.FAILURE);
|
showToast("CustomRPC application ID is already added.", Toasts.Type.FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -99,39 +107,39 @@ function ImportCustomRPCComponent() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let allowedIdsPushID: ((id: string) => boolean) | null = null;
|
let idsListPushID: ((id: string) => boolean) | null = null;
|
||||||
|
|
||||||
function AllowedIdsComponent(props: { setValue: (value: string) => void; }) {
|
function IdsListComponent(props: { setValue: (value: string) => void; }) {
|
||||||
const [allowedIds, setAllowedIds] = useState<string>(settings.store.allowedIds ?? "");
|
const [idsList, setIdsList] = useState<string>(settings.store.idsList ?? "");
|
||||||
|
|
||||||
allowedIdsPushID = (id: string) => {
|
idsListPushID = (id: string) => {
|
||||||
const currentIds = new Set(allowedIds.split(",").map(id => id.trim()).filter(Boolean));
|
const currentIds = new Set(idsList.split(",").map(id => id.trim()).filter(Boolean));
|
||||||
|
|
||||||
const isAlreadyAdded = currentIds.has(id) || (currentIds.add(id), false);
|
const isAlreadyAdded = currentIds.has(id) || (currentIds.add(id), false);
|
||||||
|
|
||||||
const ids = Array.from(currentIds).join(", ");
|
const ids = Array.from(currentIds).join(", ");
|
||||||
setAllowedIds(ids);
|
setIdsList(ids);
|
||||||
props.setValue(ids);
|
props.setValue(ids);
|
||||||
|
|
||||||
return isAlreadyAdded;
|
return isAlreadyAdded;
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => () => {
|
useEffect(() => () => {
|
||||||
allowedIdsPushID = null;
|
idsListPushID = null;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function handleChange(newValue: string) {
|
function handleChange(newValue: string) {
|
||||||
setAllowedIds(newValue);
|
setIdsList(newValue);
|
||||||
props.setValue(newValue);
|
props.setValue(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Forms.FormSection>
|
<Forms.FormSection>
|
||||||
<Forms.FormTitle tag="h3">Allowed List</Forms.FormTitle>
|
<Forms.FormTitle tag="h3">Filter List</Forms.FormTitle>
|
||||||
<Forms.FormText className={Margins.bottom8} type={Forms.FormText.Types.DESCRIPTION}>Comma separated list of activity IDs to allow (Useful for allowing RPC activities and CustomRPC)</Forms.FormText>
|
<Forms.FormText className={Margins.bottom8} type={Forms.FormText.Types.DESCRIPTION}>Comma separated list of activity IDs to filter (Useful for filtering specific RPC activities and CustomRPC</Forms.FormText>
|
||||||
<TextInput
|
<TextInput
|
||||||
type="text"
|
type="text"
|
||||||
value={allowedIds}
|
value={idsList}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
placeholder="235834946571337729, 343383572805058560"
|
placeholder="235834946571337729, 343383572805058560"
|
||||||
/>
|
/>
|
||||||
|
@ -145,40 +153,62 @@ const settings = definePluginSettings({
|
||||||
description: "",
|
description: "",
|
||||||
component: () => <ImportCustomRPCComponent />
|
component: () => <ImportCustomRPCComponent />
|
||||||
},
|
},
|
||||||
allowedIds: {
|
listMode: {
|
||||||
|
type: OptionType.SELECT,
|
||||||
|
description: "Change the mode of the filter list",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: "Whitelist",
|
||||||
|
value: FilterMode.Whitelist,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Blacklist",
|
||||||
|
value: FilterMode.Blacklist,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
onChange: recalculateActivities
|
||||||
|
},
|
||||||
|
idsList: {
|
||||||
type: OptionType.COMPONENT,
|
type: OptionType.COMPONENT,
|
||||||
description: "",
|
description: "",
|
||||||
default: "",
|
default: "",
|
||||||
onChange(newValue: string) {
|
onChange(newValue: string) {
|
||||||
const ids = new Set(newValue.split(",").map(id => id.trim()).filter(Boolean));
|
const ids = new Set(newValue.split(",").map(id => id.trim()).filter(Boolean));
|
||||||
settings.store.allowedIds = Array.from(ids).join(", ");
|
settings.store.idsList = Array.from(ids).join(", ");
|
||||||
|
recalculateActivities();
|
||||||
},
|
},
|
||||||
component: props => <AllowedIdsComponent setValue={props.setValue} />
|
component: props => <IdsListComponent setValue={props.setValue} />
|
||||||
},
|
},
|
||||||
ignorePlaying: {
|
ignorePlaying: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Ignore all playing activities (These are usually game and RPC activities)",
|
description: "Ignore all playing activities (These are usually game and RPC activities)",
|
||||||
default: false
|
default: false,
|
||||||
|
onChange: recalculateActivities
|
||||||
},
|
},
|
||||||
ignoreStreaming: {
|
ignoreStreaming: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Ignore all streaming activities",
|
description: "Ignore all streaming activities",
|
||||||
default: false
|
default: false,
|
||||||
|
onChange: recalculateActivities
|
||||||
},
|
},
|
||||||
ignoreListening: {
|
ignoreListening: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Ignore all listening activities (These are usually spotify activities)",
|
description: "Ignore all listening activities (These are usually spotify activities)",
|
||||||
default: false
|
default: false,
|
||||||
|
onChange: recalculateActivities
|
||||||
},
|
},
|
||||||
ignoreWatching: {
|
ignoreWatching: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Ignore all watching activities",
|
description: "Ignore all watching activities",
|
||||||
default: false
|
default: false,
|
||||||
|
onChange: recalculateActivities
|
||||||
},
|
},
|
||||||
ignoreCompeting: {
|
ignoreCompeting: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Ignore all competing activities (These are normally special game activities)",
|
description: "Ignore all competing activities (These are normally special game activities)",
|
||||||
default: false
|
default: false,
|
||||||
|
onChange: recalculateActivities
|
||||||
}
|
}
|
||||||
}).withPrivateSettings<{
|
}).withPrivateSettings<{
|
||||||
ignoredActivities: IgnoredActivity[];
|
ignoredActivities: IgnoredActivity[];
|
||||||
|
@ -189,8 +219,8 @@ function getIgnoredActivities() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isActivityTypeIgnored(type: number, id?: string) {
|
function isActivityTypeIgnored(type: number, id?: string) {
|
||||||
if (id && settings.store.allowedIds.includes(id)) {
|
if (id && settings.store.idsList.includes(id)) {
|
||||||
return false;
|
return settings.store.listMode === FilterMode.Blacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -206,15 +236,15 @@ function isActivityTypeIgnored(type: number, id?: string) {
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "IgnoreActivities",
|
name: "IgnoreActivities",
|
||||||
authors: [Devs.Nuckyz],
|
authors: [Devs.Nuckyz, Devs.Kylie],
|
||||||
description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below.",
|
description: "Ignore activities from showing up on your status ONLY. You can configure which ones are specifically ignored from the Registered Games and Activities tabs, or use the general settings below",
|
||||||
dependencies: ["UserSettingsAPI"],
|
dependencies: ["UserSettingsAPI"],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: '="LocalActivityStore",',
|
find: '"LocalActivityStore"',
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /HANG_STATUS.+?(?=!\i\(\)\(\i,\i\)&&)(?<=(\i)\.push.+?)/,
|
match: /HANG_STATUS.+?(?=!\i\(\)\(\i,\i\)&&)(?<=(\i)\.push.+?)/,
|
||||||
|
@ -223,7 +253,7 @@ export default definePlugin({
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: '="ActivityTrackingStore",',
|
find: '"ActivityTrackingStore"',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /getVisibleRunningGames\(\).+?;(?=for)(?<=(\i)=\i\.\i\.getVisibleRunningGames.+?)/,
|
match: /getVisibleRunningGames\(\).+?;(?=for)(?<=(\i)=\i\.\i\.getVisibleRunningGames.+?)/,
|
||||||
replace: (m, runningGames) => `${m}${runningGames}=${runningGames}.filter(({id,name})=>$self.isActivityNotIgnored({type:0,application_id:id,name}));`
|
replace: (m, runningGames) => `${m}${runningGames}=${runningGames}.filter(({id,name})=>$self.isActivityNotIgnored({type:0,application_id:id,name}));`
|
||||||
|
@ -236,6 +266,7 @@ export default definePlugin({
|
||||||
replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),`
|
replace: (m, props, nowPlaying) => `${m}$self.renderToggleGameActivityButton(${props},${nowPlaying}),`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// Discord has 2 different components for activities. Currently, the last is the one being used
|
||||||
{
|
{
|
||||||
find: ".activityTitleText,variant",
|
find: ".activityTitleText,variant",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -244,15 +275,21 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".activityCardDetails,children",
|
find: ".promotedLabelWrapperNonBanner,children",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.activityCardDetails.+?children:(\i\.application)\.name.*?}\),/,
|
match: /\.appDetailsHeaderContainer.+?children:\i.*?}\),(?<=application:(\i).+?)/,
|
||||||
replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),`
|
replace: (m, props) => `${m}$self.renderToggleActivityButton(${props}),`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
|
// Migrate allowedIds
|
||||||
|
if (Settings.plugins.IgnoreActivities.allowedIds) {
|
||||||
|
settings.store.idsList = Settings.plugins.IgnoreActivities.allowedIds;
|
||||||
|
delete Settings.plugins.IgnoreActivities.allowedIds; // Remove allowedIds
|
||||||
|
}
|
||||||
|
|
||||||
const oldIgnoredActivitiesData = await DataStore.get<Map<IgnoredActivity["id"], IgnoredActivity>>("IgnoreActivities_ignoredActivities");
|
const oldIgnoredActivitiesData = await DataStore.get<Map<IgnoredActivity["id"], IgnoredActivity>>("IgnoreActivities_ignoredActivities");
|
||||||
|
|
||||||
if (oldIgnoredActivitiesData != null) {
|
if (oldIgnoredActivitiesData != null) {
|
||||||
|
@ -279,7 +316,7 @@ export default definePlugin({
|
||||||
if (isActivityTypeIgnored(props.type, props.application_id)) return false;
|
if (isActivityTypeIgnored(props.type, props.application_id)) return false;
|
||||||
|
|
||||||
if (props.application_id != null) {
|
if (props.application_id != null) {
|
||||||
return !getIgnoredActivities().some(activity => activity.id === props.application_id) || settings.store.allowedIds.includes(props.application_id);
|
return !getIgnoredActivities().some(activity => activity.id === props.application_id) || (settings.store.listMode === FilterMode.Whitelist && settings.store.idsList.includes(props.application_id));
|
||||||
} else {
|
} else {
|
||||||
const exePath = RunningGameStore.getRunningGames().find(game => game.name === props.name)?.exePath;
|
const exePath = RunningGameStore.getRunningGames().find(game => game.name === props.name)?.exePath;
|
||||||
if (exePath) {
|
if (exePath) {
|
||||||
|
|
|
@ -156,14 +156,10 @@ export default definePlugin({
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "Messages.OPEN_IN_BROWSER",
|
find: ".contain,SCALE_DOWN:",
|
||||||
replacement: {
|
replacement: {
|
||||||
// there are 2 image thingies. one for carosuel and one for the single image.
|
match: /\.slide,\i\),/g,
|
||||||
// so thats why i added global flag.
|
replace: `$&id:"${ELEMENT_ID}",`
|
||||||
// also idk if this patch is good, should it be more specific?
|
|
||||||
// https://regex101.com/r/xfvNvV/1
|
|
||||||
match: /return.{1,200}\.wrapper.{1,200}src:\i,/g,
|
|
||||||
replace: `$&id: '${ELEMENT_ID}',`
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -183,15 +179,13 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
match: /componentWillUnmount\(\){/,
|
match: /componentWillUnmount\(\){/,
|
||||||
replace: "$&$self.unMountMagnifier();"
|
replace: "$&$self.unMountMagnifier();"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
match: /componentDidUpdate\(\i\){/,
|
||||||
|
replace: "$&$self.updateMagnifier(this);"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
find: ".carouselModal",
|
|
||||||
replacement: {
|
|
||||||
match: /(?<=\.carouselModal.{0,100}onClick:)\i,/,
|
|
||||||
replace: "()=>{},"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -226,6 +220,11 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateMagnifier(instance) {
|
||||||
|
this.unMountMagnifier();
|
||||||
|
this.renderMagnifier(instance);
|
||||||
|
},
|
||||||
|
|
||||||
unMountMagnifier() {
|
unMountMagnifier() {
|
||||||
this.root?.unmount();
|
this.root?.unmount();
|
||||||
this.currentMagnifierElement = null;
|
this.currentMagnifierElement = null;
|
||||||
|
|
|
@ -23,12 +23,3 @@
|
||||||
|
|
||||||
/* https://googlechrome.github.io/samples/image-rendering-pixelated/index.html */
|
/* https://googlechrome.github.io/samples/image-rendering-pixelated/index.html */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make the carousel take up less space so we can click the backdrop and exit out of it */
|
|
||||||
[class*="modalCarouselWrapper_"] {
|
|
||||||
top: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
[class*="carouselModal_"] {
|
|
||||||
height: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
|
@ -66,14 +66,14 @@ export function addPatch(newPatch: Omit<Patch, "plugin">, pluginName: string) {
|
||||||
patch.replacement = [patch.replacement];
|
patch.replacement = [patch.replacement];
|
||||||
}
|
}
|
||||||
|
|
||||||
patch.replacement = patch.replacement.filter(({ predicate }) => !predicate || predicate());
|
|
||||||
|
|
||||||
if (IS_REPORTER) {
|
if (IS_REPORTER) {
|
||||||
patch.replacement.forEach(r => {
|
patch.replacement.forEach(r => {
|
||||||
delete r.predicate;
|
delete r.predicate;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
patch.replacement = patch.replacement.filter(({ predicate }) => !predicate || predicate());
|
||||||
|
|
||||||
patches.push(patch);
|
patches.push(patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +105,11 @@ for (const p of pluginsValues) if (isPluginEnabled(p.name)) {
|
||||||
settings[d].enabled = true;
|
settings[d].enabled = true;
|
||||||
dep.isDependency = true;
|
dep.isDependency = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (p.commands?.length) {
|
||||||
|
Plugins.CommandsAPI.isDependency = true;
|
||||||
|
settings.CommandsAPI.enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const p of pluginsValues) {
|
for (const p of pluginsValues) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { ChannelStore, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common";
|
import { ChannelRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common";
|
||||||
|
|
||||||
export interface LogoutEvent {
|
export interface LogoutEvent {
|
||||||
type: "LOGOUT";
|
type: "LOGOUT";
|
||||||
|
@ -40,11 +40,6 @@ interface PreviousChannel {
|
||||||
let isSwitchingAccount = false;
|
let isSwitchingAccount = false;
|
||||||
let previousCache: PreviousChannel | undefined;
|
let previousCache: PreviousChannel | undefined;
|
||||||
|
|
||||||
function attemptToNavigateToChannel(guildId: string | null, channelId: string) {
|
|
||||||
if (!ChannelStore.hasChannel(channelId)) return;
|
|
||||||
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "KeepCurrentChannel",
|
name: "KeepCurrentChannel",
|
||||||
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
||||||
|
@ -59,8 +54,9 @@ export default definePlugin({
|
||||||
if (!isSwitchingAccount) return;
|
if (!isSwitchingAccount) return;
|
||||||
isSwitchingAccount = false;
|
isSwitchingAccount = false;
|
||||||
|
|
||||||
if (previousCache?.channelId)
|
if (previousCache?.channelId) {
|
||||||
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
ChannelRouter.transitionToChannel(previousCache.channelId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
|
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
|
||||||
|
@ -84,7 +80,7 @@ export default definePlugin({
|
||||||
|
|
||||||
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
||||||
} else if (previousCache.channelId) {
|
} else if (previousCache.channelId) {
|
||||||
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
ChannelRouter.transitionToChannel(previousCache.channelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,15 +5,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
|
import { isObjectEmpty } from "@utils/misc";
|
||||||
import { SelectedChannelStore, Tooltip, useEffect, useStateFromStores } from "@webpack/common";
|
import { SelectedChannelStore, Tooltip, useEffect, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
import { ChannelMemberStore, cl, GuildMemberCountStore, numberFormat } from ".";
|
import { ChannelMemberStore, cl, GuildMemberCountStore, numberFormat, ThreadMemberListStore } from ".";
|
||||||
import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
|
import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
|
||||||
|
|
||||||
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
|
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
|
||||||
const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());
|
const currentChannel = useStateFromStores([SelectedChannelStore], () => getCurrentChannel());
|
||||||
|
|
||||||
const guildId = isTooltip ? tooltipGuildId! : currentChannel.guild_id;
|
const guildId = isTooltip ? tooltipGuildId! : currentChannel?.guild_id;
|
||||||
|
|
||||||
const totalCount = useStateFromStores(
|
const totalCount = useStateFromStores(
|
||||||
[GuildMemberCountStore],
|
[GuildMemberCountStore],
|
||||||
|
@ -30,10 +31,19 @@ export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; t
|
||||||
() => ChannelMemberStore.getProps(guildId, currentChannel?.id)
|
() => ChannelMemberStore.getProps(guildId, currentChannel?.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const threadGroups = useStateFromStores(
|
||||||
|
[ThreadMemberListStore],
|
||||||
|
() => ThreadMemberListStore.getMemberListSections(currentChannel?.id)
|
||||||
|
);
|
||||||
|
|
||||||
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {
|
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {
|
||||||
onlineCount = groups.reduce((total, curr) => total + (curr.id === "offline" ? 0 : curr.count), 0);
|
onlineCount = groups.reduce((total, curr) => total + (curr.id === "offline" ? 0 : curr.count), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isTooltip && threadGroups && !isObjectEmpty(threadGroups)) {
|
||||||
|
onlineCount = Object.values(threadGroups).reduce((total, curr) => total + (curr.sectionId === "offline" ? 0 : curr.userIds.length), 0);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
OnlineMemberCountStore.ensureCount(guildId);
|
OnlineMemberCountStore.ensureCount(guildId);
|
||||||
}, [guildId]);
|
}, [guildId]);
|
||||||
|
|
|
@ -15,8 +15,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
|
||||||
const onlineMemberMap = new Map<string, number>();
|
const onlineMemberMap = new Map<string, number>();
|
||||||
|
|
||||||
class OnlineMemberCountStore extends Flux.Store {
|
class OnlineMemberCountStore extends Flux.Store {
|
||||||
getCount(guildId: string) {
|
getCount(guildId?: string) {
|
||||||
return onlineMemberMap.get(guildId);
|
return onlineMemberMap.get(guildId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _ensureCount(guildId: string) {
|
async _ensureCount(guildId: string) {
|
||||||
|
@ -25,8 +25,8 @@ export const OnlineMemberCountStore = proxyLazy(() => {
|
||||||
await PrivateChannelsStore.preload(guildId, GuildChannelStore.getDefaultChannel(guildId).id);
|
await PrivateChannelsStore.preload(guildId, GuildChannelStore.getDefaultChannel(guildId).id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureCount(guildId: string) {
|
ensureCount(guildId?: string) {
|
||||||
if (onlineMemberMap.has(guildId)) return;
|
if (!guildId || onlineMemberMap.has(guildId)) return;
|
||||||
|
|
||||||
preloadQueue.push(() =>
|
preloadQueue.push(() =>
|
||||||
this._ensureCount(guildId)
|
this._ensureCount(guildId)
|
||||||
|
|
|
@ -28,10 +28,14 @@ import { FluxStore } from "@webpack/types";
|
||||||
|
|
||||||
import { MemberCount } from "./MemberCount";
|
import { MemberCount } from "./MemberCount";
|
||||||
|
|
||||||
export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId: string): number | null; };
|
export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as FluxStore & { getMemberCount(guildId?: string): number | null; };
|
||||||
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
||||||
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
getProps(guildId?: string, channelId?: string): { groups: { count: number; id: string; }[]; };
|
||||||
};
|
};
|
||||||
|
export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & {
|
||||||
|
getMemberListSections(channelId?: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
toolTip: {
|
toolTip: {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# MentionAvatars
|
# MentionAvatars
|
||||||
|
|
||||||
Shows user avatars inside mentions
|
Shows user avatars and role icons inside mentions
|
||||||
|
|
||||||

|

|
||||||
|

|
||||||
|
|
|
@ -10,21 +10,42 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { SelectedGuildStore, useState } from "@webpack/common";
|
import { GuildStore, SelectedGuildStore, useState } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
showAtSymbol: {
|
showAtSymbol: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Whether the the @ symbol should be displayed",
|
description: "Whether the the @ symbol should be displayed on user mentions",
|
||||||
default: true
|
default: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function DefaultRoleIcon() {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
className="vc-mentionAvatars-icon vc-mentionAvatars-role-icon"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M14 8.00598C14 10.211 12.206 12.006 10 12.006C7.795 12.006 6 10.211 6 8.00598C6 5.80098 7.794 4.00598 10 4.00598C12.206 4.00598 14 5.80098 14 8.00598ZM2 19.006C2 15.473 5.29 13.006 10 13.006C14.711 13.006 18 15.473 18 19.006V20.006H2V19.006Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M20.0001 20.006H22.0001V19.006C22.0001 16.4433 20.2697 14.4415 17.5213 13.5352C19.0621 14.9127 20.0001 16.8059 20.0001 19.006V20.006Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M14.8834 11.9077C16.6657 11.5044 18.0001 9.9077 18.0001 8.00598C18.0001 5.96916 16.4693 4.28218 14.4971 4.0367C15.4322 5.09511 16.0001 6.48524 16.0001 8.00598C16.0001 9.44888 15.4889 10.7742 14.6378 11.8102C14.7203 11.8418 14.8022 11.8743 14.8834 11.9077Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MentionAvatars",
|
name: "MentionAvatars",
|
||||||
description: "Shows user avatars inside mentions",
|
description: "Shows user avatars and role icons inside mentions",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven, Devs.SerStars],
|
||||||
|
|
||||||
patches: [{
|
patches: [{
|
||||||
find: ".USER_MENTION)",
|
find: ".USER_MENTION)",
|
||||||
|
@ -32,6 +53,13 @@ export default definePlugin({
|
||||||
match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/,
|
match: /children:"@"\.concat\((null!=\i\?\i:\i)\)(?<=\.useName\((\i)\).+?)/,
|
||||||
replace: "children:$self.renderUsername({username:$1,user:$2})"
|
replace: "children:$self.renderUsername({username:$1,user:$2})"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".ROLE_MENTION)",
|
||||||
|
replacement: {
|
||||||
|
match: /children:\[\i&&.{0,50}\.RoleDot.{0,300},\i(?=\])/,
|
||||||
|
replace: "$&,$self.renderRoleIcon(arguments[0])"
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
settings,
|
settings,
|
||||||
|
@ -47,12 +75,31 @@ export default definePlugin({
|
||||||
onMouseEnter={() => setIsHovering(true)}
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
onMouseLeave={() => setIsHovering(false)}
|
onMouseLeave={() => setIsHovering(false)}
|
||||||
>
|
>
|
||||||
<img src={user.getAvatarURL(SelectedGuildStore.getGuildId(), 16, isHovering)} className="vc-mentionAvatars-avatar" />
|
<img
|
||||||
|
src={user.getAvatarURL(SelectedGuildStore.getGuildId(), 16, isHovering)}
|
||||||
|
className="vc-mentionAvatars-icon"
|
||||||
|
style={{ borderRadius: "50%" }}
|
||||||
|
/>
|
||||||
{getUsernameString(username)}
|
{getUsernameString(username)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}, { noop: true })
|
}, { noop: true }),
|
||||||
|
|
||||||
|
renderRoleIcon: ErrorBoundary.wrap(({ roleId, guildId }: { roleId: string, guildId: string; }) => {
|
||||||
|
// Discord uses Role Mentions for uncached users because .... idk
|
||||||
|
if (!roleId) return null;
|
||||||
|
|
||||||
|
const role = GuildStore.getRole(guildId, roleId);
|
||||||
|
|
||||||
|
if (!role?.icon) return <DefaultRoleIcon />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
className="vc-mentionAvatars-icon vc-mentionAvatars-role-icon"
|
||||||
|
src={`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${roleId}/${role.icon}.webp?size=24&quality=lossless`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
function getUsernameString(username: string) {
|
function getUsernameString(username: string) {
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
.vc-mentionAvatars-avatar {
|
.vc-mentionAvatars-icon {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
width: 1em !important; /* insane discord sets width: 100% in channel topic */
|
width: 1em !important; /* insane discord sets width: 100% in channel topic */
|
||||||
height: 1em;
|
height: 1em;
|
||||||
margin: 0 4px 0.2rem 2px;
|
margin: 0 4px 0.2rem 2px;
|
||||||
border-radius: 50%;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-mentionAvatars-role-icon {
|
||||||
|
margin: 0 2px 0.2rem 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** don't display inside the ServerInfo modal owner mention */
|
||||||
|
.vc-gp-owner .vc-mentionAvatars-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default definePlugin({
|
||||||
if (msg.deleted === true) return;
|
if (msg.deleted === true) return;
|
||||||
|
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
if (!settings.store.enableDoubleClickToEdit || EditStore.isEditing(channel.id, msg.id)) return;
|
if (!settings.store.enableDoubleClickToEdit || EditStore.isEditing(channel.id, msg.id) || msg.state !== "SENT") return;
|
||||||
|
|
||||||
MessageActions.startEditMessage(channel.id, msg.id, msg.content);
|
MessageActions.startEditMessage(channel.id, msg.id, msg.content);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
@ -82,7 +82,6 @@ export default definePlugin({
|
||||||
default: true
|
default: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
for (const tag of await getTags()) createTagCommand(tag);
|
for (const tag of await getTags()) createTagCommand(tag);
|
||||||
|
|
|
@ -33,7 +33,6 @@ export default definePlugin({
|
||||||
name: "MoreCommands",
|
name: "MoreCommands",
|
||||||
description: "echo, lenny, mock",
|
description: "echo, lenny, mock",
|
||||||
authors: [Devs.Arjix, Devs.echo, Devs.Samu],
|
authors: [Devs.Arjix, Devs.echo, Devs.Samu],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
name: "echo",
|
name: "echo",
|
||||||
|
|
|
@ -24,7 +24,6 @@ export default definePlugin({
|
||||||
name: "MoreKaomoji",
|
name: "MoreKaomoji",
|
||||||
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
description: "Adds more Kaomoji to discord. ヽ(´▽`)/",
|
||||||
authors: [Devs.JacobTm],
|
authors: [Devs.JacobTm],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{ name: "dissatisfaction", description: " >﹏<" },
|
{ name: "dissatisfaction", description: " >﹏<" },
|
||||||
{ name: "smug", description: "ಠ_ಠ" },
|
{ name: "smug", description: "ಠ_ಠ" },
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy, findLazy } from "@webpack";
|
import { findByCodeLazy, findLazy } from "@webpack";
|
||||||
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip, useState } from "@webpack/common";
|
import { Card, ChannelStore, Forms, GuildStore, PermissionsBits, Switch, TextInput, Tooltip } from "@webpack/common";
|
||||||
import type { Permissions, RC } from "@webpack/types";
|
import type { Permissions, RC } from "@webpack/types";
|
||||||
import type { Channel, Guild, Message, User } from "discord-types/general";
|
import type { Channel, Guild, Message, User } from "discord-types/general";
|
||||||
|
|
||||||
|
@ -107,14 +107,8 @@ const defaultSettings = Object.fromEntries(
|
||||||
tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }])
|
tags.map(({ name, displayName }) => [name, { text: displayName, showInChat: true, showInNotChat: true }])
|
||||||
) as TagSettings;
|
) as TagSettings;
|
||||||
|
|
||||||
function SettingsComponent(props: { setValue(v: any): void; }) {
|
function SettingsComponent() {
|
||||||
settings.store.tagSettings ??= defaultSettings;
|
const tagSettings = settings.store.tagSettings ??= defaultSettings;
|
||||||
|
|
||||||
const [tagSettings, setTagSettings] = useState(settings.store.tagSettings as TagSettings);
|
|
||||||
const setValue = (v: TagSettings) => {
|
|
||||||
setTagSettings(v);
|
|
||||||
props.setValue(v);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection="column">
|
<Flex flexDirection="column">
|
||||||
|
@ -137,19 +131,13 @@ function SettingsComponent(props: { setValue(v: any): void; }) {
|
||||||
type="text"
|
type="text"
|
||||||
value={tagSettings[t.name]?.text ?? t.displayName}
|
value={tagSettings[t.name]?.text ?? t.displayName}
|
||||||
placeholder={`Text on tag (default: ${t.displayName})`}
|
placeholder={`Text on tag (default: ${t.displayName})`}
|
||||||
onChange={v => {
|
onChange={v => tagSettings[t.name].text = v}
|
||||||
tagSettings[t.name].text = v;
|
|
||||||
setValue(tagSettings);
|
|
||||||
}}
|
|
||||||
className={Margins.bottom16}
|
className={Margins.bottom16}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
value={tagSettings[t.name]?.showInChat ?? true}
|
value={tagSettings[t.name]?.showInChat ?? true}
|
||||||
onChange={v => {
|
onChange={v => tagSettings[t.name].showInChat = v}
|
||||||
tagSettings[t.name].showInChat = v;
|
|
||||||
setValue(tagSettings);
|
|
||||||
}}
|
|
||||||
hideBorder
|
hideBorder
|
||||||
>
|
>
|
||||||
Show in messages
|
Show in messages
|
||||||
|
@ -157,10 +145,7 @@ function SettingsComponent(props: { setValue(v: any): void; }) {
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
value={tagSettings[t.name]?.showInNotChat ?? true}
|
value={tagSettings[t.name]?.showInNotChat ?? true}
|
||||||
onChange={v => {
|
onChange={v => tagSettings[t.name].showInNotChat = v}
|
||||||
tagSettings[t.name].showInNotChat = v;
|
|
||||||
setValue(tagSettings);
|
|
||||||
}}
|
|
||||||
hideBorder
|
hideBorder
|
||||||
>
|
>
|
||||||
Show in member list and profiles
|
Show in member list and profiles
|
||||||
|
@ -183,7 +168,7 @@ const settings = definePluginSettings({
|
||||||
tagSettings: {
|
tagSettings: {
|
||||||
type: OptionType.COMPONENT,
|
type: OptionType.COMPONENT,
|
||||||
component: SettingsComponent,
|
component: SettingsComponent,
|
||||||
description: "fill me",
|
description: "fill me"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -247,9 +232,9 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: 'copyMetaData:"User Tag"',
|
find: ".Messages.USER_PROFILE_PRONOUNS",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?=,botClass:)/,
|
match: /(?=,hideBotTag:!0)/,
|
||||||
replace: ",moreTags_channelId:arguments[0].moreTags_channelId"
|
replace: ",moreTags_channelId:arguments[0].moreTags_channelId"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -264,8 +249,8 @@ export default definePlugin({
|
||||||
match: /user:\i,nick:\i,/,
|
match: /user:\i,nick:\i,/,
|
||||||
replace: "$&moreTags_channelId,"
|
replace: "$&moreTags_channelId,"
|
||||||
}, {
|
}, {
|
||||||
match: /,botType:(\i),(?<=user:(\i).+?)/g,
|
match: /,botType:(\i),botVerified:(\i),(?!discriminatorClass:)(?<=user:(\i).+?)/g,
|
||||||
replace: ",botType:$self.getTag({user:$2,channelId:moreTags_channelId,origType:$1,location:'not-chat'}),"
|
replace: ",botType:$self.getTag({user:$3,channelId:moreTags_channelId,origType:$1,location:'not-chat'}),botVerified:$2,"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,14 +20,15 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { isNonNullish } from "@utils/guards";
|
import { isNonNullish } from "@utils/guards";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
|
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, useMemo, UserStore } from "@webpack/common";
|
||||||
import { Channel, User } from "discord-types/general";
|
import { Channel, User } from "discord-types/general";
|
||||||
|
|
||||||
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
||||||
const UserUtils = findByPropsLazy("getGlobalName");
|
const UserUtils = findByPropsLazy("getGlobalName");
|
||||||
|
|
||||||
const ProfileListClasses = findByPropsLazy("emptyIconFriends", "emptyIconGuilds");
|
const ProfileListClasses = findByPropsLazy("emptyIconFriends", "emptyIconGuilds");
|
||||||
|
const ExpandableList = findComponentByCodeLazy('"PRESS_SECTION"');
|
||||||
const GuildLabelClasses = findByPropsLazy("guildNick", "guildAvatarWithoutIcon");
|
const GuildLabelClasses = findByPropsLazy("guildNick", "guildAvatarWithoutIcon");
|
||||||
|
|
||||||
function getGroupDMName(channel: Channel) {
|
function getGroupDMName(channel: Channel) {
|
||||||
|
@ -39,69 +40,84 @@ function getGroupDMName(channel: Channel) {
|
||||||
.join(", ");
|
.join(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMutualGroupDms = (userId: string) =>
|
||||||
|
ChannelStore.getSortedPrivateChannels()
|
||||||
|
.filter(c => c.isGroupDM() && c.recipients.includes(userId));
|
||||||
|
|
||||||
|
const isBotOrSelf = (user: User) => user.bot || user.id === UserStore.getCurrentUser().id;
|
||||||
|
|
||||||
|
function getMutualGDMCountText(user: User) {
|
||||||
|
const count = getMutualGroupDms(user.id).length;
|
||||||
|
return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderClickableGDMs(mutualDms: Channel[], onClose: () => void) {
|
||||||
|
return mutualDms.map(c => (
|
||||||
|
<Clickable
|
||||||
|
className={ProfileListClasses.listRow}
|
||||||
|
onClick={() => {
|
||||||
|
onClose();
|
||||||
|
SelectedChannelActionCreators.selectPrivateChannel(c.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Avatar
|
||||||
|
src={IconUtils.getChannelIconURL({ id: c.id, icon: c.icon, size: 32 })}
|
||||||
|
size="SIZE_40"
|
||||||
|
className={ProfileListClasses.listAvatar}
|
||||||
|
>
|
||||||
|
</Avatar>
|
||||||
|
<div className={ProfileListClasses.listRowContent}>
|
||||||
|
<div className={ProfileListClasses.listName}>{getGroupDMName(c)}</div>
|
||||||
|
<div className={GuildLabelClasses.guildNick}>{c.recipients.length + 1} Members</div>
|
||||||
|
</div>
|
||||||
|
</Clickable>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
const IS_PATCHED = Symbol("MutualGroupDMs.Patched");
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "MutualGroupDMs",
|
name: "MutualGroupDMs",
|
||||||
description: "Shows mutual group dms in profiles",
|
description: "Shows mutual group dms in profiles",
|
||||||
authors: [Devs.amia],
|
authors: [Devs.amia],
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
|
||||||
find: ".Messages.MUTUAL_GUILDS_WITH_END_COUNT", // Note: the module is lazy-loaded
|
|
||||||
replacement: {
|
|
||||||
match: /(?<=\.tabBarItem.{0,50}MUTUAL_GUILDS.+?}\),)(?=.+?(\(0,\i\.jsxs?\)\(.{0,100}id:))/,
|
|
||||||
replace: '$self.isBotOrSelf(arguments[0].user)?null:$1"MUTUAL_GDMS",children:$self.getMutualGDMCountText(arguments[0].user)}),'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: ".USER_INFO_CONNECTIONS:case",
|
|
||||||
replacement: {
|
|
||||||
match: /(?<={user:(\i),onClose:(\i)}\);)(?=case \i\.\i\.MUTUAL_FRIENDS)/,
|
|
||||||
replace: "case \"MUTUAL_GDMS\":return $self.renderMutualGDMs({user: $1, onClose: $2});"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: ".MUTUAL_FRIENDS?(",
|
find: ".MUTUAL_FRIENDS?(",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /(?<=onItemSelect:\i,children:)(\i)\.map/,
|
match: /\i\.useEffect.{0,100}(\i)\[0\]\.section/,
|
||||||
replace: "[...$1, ...($self.isBotOrSelf(arguments[0].user) ? [] : [{section:'MUTUAL_GDMS',text:$self.getMutualGDMCountText(arguments[0].user)}])].map"
|
replace: "$self.pushSection($1, arguments[0].user);$&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/,
|
match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/,
|
||||||
replace: "$1==='MUTUAL_GDMS'?$self.renderMutualGDMs(arguments[0]):$&"
|
replace: "$1==='MUTUAL_GDMS'?$self.renderMutualGDMs(arguments[0]):$&"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: 'section:"MUTUAL_FRIENDS"',
|
||||||
|
replacement: {
|
||||||
|
match: /\.openUserProfileModal.+?\)}\)}\)(?<=(\(0,\i\.jsxs?\)\(\i\.\i,{className:(\i)\.divider}\)).+?)/,
|
||||||
|
replace: "$&,$self.renderDMPageList({user: arguments[0].user, Divider: $1, listStyle: $2.list})"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
isBotOrSelf: (user: User) => user.bot || user.id === UserStore.getCurrentUser().id,
|
pushSection(sections: any[], user: User) {
|
||||||
|
if (isBotOrSelf(user) || sections[IS_PATCHED]) return;
|
||||||
|
|
||||||
getMutualGDMCountText: (user: User) => {
|
sections[IS_PATCHED] = true;
|
||||||
const count = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).length;
|
sections.push({
|
||||||
return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`;
|
section: "MUTUAL_GDMS",
|
||||||
|
text: getMutualGDMCountText(user)
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
||||||
const entries = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).map(c => (
|
const mutualGDms = useMemo(() => getMutualGroupDms(user.id), [user.id]);
|
||||||
<Clickable
|
|
||||||
className={ProfileListClasses.listRow}
|
const entries = renderClickableGDMs(mutualGDms, onClose);
|
||||||
onClick={() => {
|
|
||||||
onClose();
|
|
||||||
SelectedChannelActionCreators.selectPrivateChannel(c.id);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Avatar
|
|
||||||
src={IconUtils.getChannelIconURL({ id: c.id, icon: c.icon, size: 32 })}
|
|
||||||
size="SIZE_40"
|
|
||||||
className={ProfileListClasses.listAvatar}
|
|
||||||
>
|
|
||||||
</Avatar>
|
|
||||||
<div className={ProfileListClasses.listRowContent}>
|
|
||||||
<div className={ProfileListClasses.listName}>{getGroupDMName(c)}</div>
|
|
||||||
<div className={GuildLabelClasses.guildNick}>{c.recipients.length + 1} Members</div>
|
|
||||||
</div>
|
|
||||||
</Clickable>
|
|
||||||
));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollerThin
|
<ScrollerThin
|
||||||
|
@ -120,5 +136,23 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
</ScrollerThin>
|
</ScrollerThin>
|
||||||
);
|
);
|
||||||
|
}),
|
||||||
|
|
||||||
|
renderDMPageList: ErrorBoundary.wrap(({ user, Divider, listStyle }: { user: User, Divider: JSX.Element, listStyle: string; }) => {
|
||||||
|
const mutualGDms = getMutualGroupDms(user.id);
|
||||||
|
if (mutualGDms.length === 0) return null;
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{Divider}
|
||||||
|
<ExpandableList
|
||||||
|
listClassName={listStyle}
|
||||||
|
header={"Mutual Groups"}
|
||||||
|
isLoading={false}
|
||||||
|
items={renderClickableGDMs(mutualGDms, () => { })}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,6 +25,12 @@ import { Message } from "discord-types/general";
|
||||||
|
|
||||||
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
||||||
|
|
||||||
|
interface MessageDeleteProps {
|
||||||
|
collapsedReason: {
|
||||||
|
message: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoBlockedMessages",
|
name: "NoBlockedMessages",
|
||||||
description: "Hides all blocked messages from chat completely.",
|
description: "Hides all blocked messages from chat completely.",
|
||||||
|
@ -35,13 +41,13 @@ export default definePlugin({
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /let\{[^}]*collapsedReason[^}]*\}/,
|
match: /let\{[^}]*collapsedReason[^}]*\}/,
|
||||||
replace: "return null;$&"
|
replace: "if($self.shouldHide(arguments[0]))return null;$&"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
...[
|
...[
|
||||||
'="MessageStore",',
|
'"MessageStore"',
|
||||||
'"displayName","ReadStateStore")'
|
'"ReadStateStore"'
|
||||||
].map(find => ({
|
].map(find => ({
|
||||||
find,
|
find,
|
||||||
predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true,
|
predicate: () => Settings.plugins.NoBlockedMessages.ignoreBlockedMessages === true,
|
||||||
|
@ -68,5 +74,9 @@ export default definePlugin({
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e);
|
new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
shouldHide(props: MessageDeleteProps) {
|
||||||
|
return !props?.collapsedReason?.message.includes("deleted");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# NoDefaultHangStatus
|
|
||||||
|
|
||||||
Disable the default hang status when joining voice channels
|
|
||||||
|
|
||||||

|
|
3
src/plugins/noMaskedUrlPaste/README.md
Normal file
3
src/plugins/noMaskedUrlPaste/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# NoMaskedUrlPaste
|
||||||
|
|
||||||
|
Pasting a link while you have text selected will NOT paste your link as a masked link.
|
23
src/plugins/noMaskedUrlPaste/index.ts
Normal file
23
src/plugins/noMaskedUrlPaste/index.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants.js";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "NoMaskedUrlPaste",
|
||||||
|
authors: [Devs.CatNoir],
|
||||||
|
description: "Pasting a link while having text selected will not paste as masked URL",
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: ".selection,preventEmojiSurrogates:",
|
||||||
|
replacement: {
|
||||||
|
match: /if\(null!=\i.selection&&\i.\i.isExpanded\(\i.selection\)\)/,
|
||||||
|
replace: "if(false)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
});
|
|
@ -62,16 +62,7 @@ export default definePlugin({
|
||||||
replace: "return 0;"
|
replace: "return 0;"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// New message requests hook
|
// Message requests hook
|
||||||
{
|
|
||||||
find: 'location:"use-message-requests-count"',
|
|
||||||
predicate: () => settings.store.hideMessageRequestsCount,
|
|
||||||
replacement: {
|
|
||||||
match: /getNonChannelAckId\(\i\.\i\.MESSAGE_REQUESTS\).+?return /,
|
|
||||||
replace: "$&0;"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Old message requests hook
|
|
||||||
{
|
{
|
||||||
find: "getMessageRequestsCount(){",
|
find: "getMessageRequestsCount(){",
|
||||||
predicate: () => settings.store.hideMessageRequestsCount,
|
predicate: () => settings.store.hideMessageRequestsCount,
|
||||||
|
@ -83,7 +74,7 @@ export default definePlugin({
|
||||||
// This prevents the Message Requests tab from always hiding due to the previous patch (and is compatible with spam requests)
|
// This prevents the Message Requests tab from always hiding due to the previous patch (and is compatible with spam requests)
|
||||||
// In short, only the red badge is hidden. Button visibility behavior isn't changed.
|
// In short, only the red badge is hidden. Button visibility behavior isn't changed.
|
||||||
{
|
{
|
||||||
find: ".getSpamChannelsCount(),",
|
find: ".getSpamChannelsCount()",
|
||||||
predicate: () => settings.store.hideMessageRequestsCount,
|
predicate: () => settings.store.hideMessageRequestsCount,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=getSpamChannelsCount\(\),\i=)\i\.getMessageRequestsCount\(\)/,
|
match: /(?<=getSpamChannelsCount\(\),\i=)\i\.getMessageRequestsCount\(\)/,
|
||||||
|
@ -96,7 +87,7 @@ export default definePlugin({
|
||||||
replacement: {
|
replacement: {
|
||||||
// The two groups inside the first group grab the minified names of the variables,
|
// The two groups inside the first group grab the minified names of the variables,
|
||||||
// they are then referenced later to find unviewedTrialCount + unviewedDiscountCount.
|
// they are then referenced later to find unviewedTrialCount + unviewedDiscountCount.
|
||||||
match: /(?<=\{unviewedTrialCount:(\i),unviewedDiscountCount:(\i)\}.{0,200}\i=)\1\+\2/,
|
match: /(?<=\{unviewedTrialCount:(\i),unviewedDiscountCount:(\i)\}.{0,300}\i=)\1\+\2/,
|
||||||
replace: "0"
|
replace: "0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,36 +18,21 @@
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
import { UserStore } from "@webpack/common";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoProfileThemes",
|
name: "NoProfileThemes",
|
||||||
description: "Completely removes Nitro profile themes",
|
description: "Completely removes Nitro profile themes from everyone but yourself",
|
||||||
authors: [Devs.TheKodeToad],
|
authors: [Devs.TheKodeToad],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
|
||||||
find: ".NITRO_BANNER,",
|
|
||||||
replacement: {
|
|
||||||
// = isPremiumAtLeast(user.premiumType, TIER_2)
|
|
||||||
match: /=(?=\i\.\i\.isPremiumAtLeast\(null==(\i))/,
|
|
||||||
// = user.banner && isPremiumAtLeast(user.premiumType, TIER_2)
|
|
||||||
replace: "=(arguments[0]?.bannerSrc||$1?.banner)&&"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: ".avatarPositionPremiumNoBanner,default:",
|
|
||||||
replacement: {
|
|
||||||
// premiumUserWithoutBanner: foo().avatarPositionPremiumNoBanner, default: foo().avatarPositionNormal
|
|
||||||
match: /\.avatarPositionPremiumNoBanner(?=,default:\i\.(\i))/,
|
|
||||||
// premiumUserWithoutBanner: foo().avatarPositionNormal...
|
|
||||||
replace: ".$1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: "hasThemeColors(){",
|
find: "hasThemeColors(){",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /get canUsePremiumProfileCustomization\(\){return /,
|
match: /get canUsePremiumProfileCustomization\(\){return /,
|
||||||
replace: "$&false &&"
|
replace: "$&$self.isCurrentUser(this.userId)&&"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
|
|
||||||
|
isCurrentUser: (userId: string) => userId === UserStore.getCurrentUser()?.id,
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
shouldSkip(guildId: string, emoji: any) {
|
shouldSkip(guildId: string, emoji: any) {
|
||||||
if (emoji.type !== "GUILD_EMOJI") {
|
if (emoji.type !== 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (settings.store.shownEmojis === "onlyUnicode") {
|
if (settings.store.shownEmojis === "onlyUnicode") {
|
||||||
|
|
|
@ -33,7 +33,7 @@ interface URLReplacementRule {
|
||||||
// Do not forget to add protocols to the ALLOWED_PROTOCOLS constant
|
// Do not forget to add protocols to the ALLOWED_PROTOCOLS constant
|
||||||
const UrlReplacementRules: Record<string, URLReplacementRule> = {
|
const UrlReplacementRules: Record<string, URLReplacementRule> = {
|
||||||
spotify: {
|
spotify: {
|
||||||
match: /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user|episode)\/(.+)(?:\?.+?)?$/,
|
match: /^https:\/\/open\.spotify\.com\/(?:intl-[a-z]{2}\/)?(track|album|artist|playlist|user|episode|prerelease)\/(.+)(?:\?.+?)?$/,
|
||||||
replace: (_, type, id) => `spotify://${type}/${id}`,
|
replace: (_, type, id) => `spotify://${type}/${id}`,
|
||||||
description: "Open Spotify links in the Spotify app",
|
description: "Open Spotify links in the Spotify app",
|
||||||
shortlinkMatch: /^https:\/\/spotify\.link\/.+$/,
|
shortlinkMatch: /^https:\/\/spotify\.link\/.+$/,
|
||||||
|
@ -91,14 +91,19 @@ export default definePlugin({
|
||||||
replace: "async function $1 if(await $self.handleLink(...arguments)) return;"
|
replace: "async function $1 if(await $self.handleLink(...arguments)) return;"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Make Spotify profile activity links open in app on web
|
|
||||||
{
|
{
|
||||||
find: "WEB_OPEN(",
|
find: "no artist ids in metadata",
|
||||||
predicate: () => !IS_DISCORD_DESKTOP && pluginSettings.store.spotify,
|
predicate: () => !IS_DISCORD_DESKTOP && pluginSettings.store.spotify,
|
||||||
replacement: {
|
replacement: [
|
||||||
match: /\i\.\i\.isProtocolRegistered\(\)(.{0,100})window.open/g,
|
{
|
||||||
replace: "true$1VencordNative.native.openExternal"
|
match: /\i\.\i\.isProtocolRegistered\(\)/g,
|
||||||
}
|
replace: "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: /!\(0,\i\.isDesktop\)\(\)/,
|
||||||
|
replace: "false"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".CONNECTED_ACCOUNT_VIEWED,",
|
find: ".CONNECTED_ACCOUNT_VIEWED,",
|
||||||
|
|
|
@ -19,16 +19,11 @@
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findLazy } from "@webpack";
|
|
||||||
import { Constants, GuildStore, i18n, RestAPI } from "@webpack/common";
|
import { Constants, GuildStore, i18n, RestAPI } from "@webpack/common";
|
||||||
|
|
||||||
const InvitesDisabledExperiment = findLazy(m => m.definition?.id === "2022-07_invites_disabled");
|
|
||||||
|
|
||||||
function showDisableInvites(guildId: string) {
|
function showDisableInvites(guildId: string) {
|
||||||
// Once the experiment is removed, this should keep working
|
|
||||||
const { enableInvitesDisabled } = InvitesDisabledExperiment?.getCurrentConfig?.({ guildId }) ?? { enableInvitesDisabled: true };
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return enableInvitesDisabled && !GuildStore.getGuild(guildId).hasFeature("INVITES_DISABLED");
|
return !GuildStore.getGuild(guildId).hasFeature("INVITES_DISABLED");
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableInvites(guildId: string) {
|
function disableInvites(guildId: string) {
|
||||||
|
|
|
@ -21,8 +21,10 @@ import { Flex } from "@components/Flex";
|
||||||
import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
|
import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
|
||||||
import { getUniqueUsername } from "@utils/discord";
|
import { getUniqueUsername } from "@utils/discord";
|
||||||
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import { Clipboard, ContextMenuApi, FluxDispatcher, GuildMemberStore, GuildStore, i18n, Menu, PermissionsBits, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
|
import { findByCodeLazy } from "@webpack";
|
||||||
import type { Guild } from "discord-types/general";
|
import { Clipboard, ContextMenuApi, FluxDispatcher, GuildMemberStore, GuildStore, i18n, Menu, PermissionsBits, ScrollerThin, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||||
|
import { UnicodeEmoji } from "@webpack/types";
|
||||||
|
import type { Guild, Role, User } from "discord-types/general";
|
||||||
|
|
||||||
import { settings } from "..";
|
import { settings } from "..";
|
||||||
import { cl, getPermissionDescription, getPermissionString } from "../utils";
|
import { cl, getPermissionDescription, getPermissionString } from "../utils";
|
||||||
|
@ -42,15 +44,15 @@ export interface RoleOrUserPermission {
|
||||||
overwriteDeny?: bigint;
|
overwriteDeny?: bigint;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openRolesAndUsersPermissionsModal(permissions: Array<RoleOrUserPermission>, guild: Guild, header: string) {
|
type GetRoleIconData = (role: Role, size: number) => { customIconSrc?: string; unicodeEmoji?: UnicodeEmoji; };
|
||||||
return openModal(modalProps => (
|
const getRoleIconData: GetRoleIconData = findByCodeLazy("convertSurrogateToName", "customIconSrc", "unicodeEmoji");
|
||||||
<RolesAndUsersPermissions
|
|
||||||
modalProps={modalProps}
|
function getRoleIconSrc(role: Role) {
|
||||||
permissions={permissions}
|
const icon = getRoleIconData(role, 20);
|
||||||
guild={guild}
|
if (!icon) return;
|
||||||
header={header}
|
|
||||||
/>
|
const { customIconSrc, unicodeEmoji } = icon;
|
||||||
));
|
return customIconSrc ?? unicodeEmoji?.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, header }: { permissions: Array<RoleOrUserPermission>; guild: Guild; modalProps: ModalProps; header: string; }) {
|
function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, header }: { permissions: Array<RoleOrUserPermission>; guild: Guild; modalProps: ModalProps; header: string; }) {
|
||||||
|
@ -86,31 +88,34 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
size={ModalSize.LARGE}
|
size={ModalSize.LARGE}
|
||||||
>
|
>
|
||||||
<ModalHeader>
|
<ModalHeader>
|
||||||
<Text className={cl("perms-title")} variant="heading-lg/semibold">{header} permissions:</Text>
|
<Text className={cl("modal-title")} variant="heading-lg/semibold">{header} permissions:</Text>
|
||||||
<ModalCloseButton onClick={modalProps.onClose} />
|
<ModalCloseButton onClick={modalProps.onClose} />
|
||||||
</ModalHeader>
|
</ModalHeader>
|
||||||
|
|
||||||
<ModalContent>
|
<ModalContent className={cl("modal-content")}>
|
||||||
{!selectedItem && (
|
{!selectedItem && (
|
||||||
<div className={cl("perms-no-perms")}>
|
<div className={cl("modal-no-perms")}>
|
||||||
<Text variant="heading-lg/normal">No permissions to display!</Text>
|
<Text variant="heading-lg/normal">No permissions to display!</Text>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{selectedItem && (
|
{selectedItem && (
|
||||||
<div className={cl("perms-container")}>
|
<div className={cl("modal-container")}>
|
||||||
<div className={cl("perms-list")}>
|
<ScrollerThin className={cl("modal-list")} orientation="auto">
|
||||||
{permissions.map((permission, index) => {
|
{permissions.map((permission, index) => {
|
||||||
const user = UserStore.getUser(permission.id ?? "");
|
const user: User | undefined = UserStore.getUser(permission.id ?? "");
|
||||||
const role = roles[permission.id ?? ""];
|
const role: Role | undefined = roles[permission.id ?? ""];
|
||||||
|
const roleIconSrc = role != null ? getRoleIconSrc(role) : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<div
|
||||||
className={cl("perms-list-item-btn")}
|
className={cl("modal-list-item-btn")}
|
||||||
onClick={() => selectItem(index)}
|
onClick={() => selectItem(index)}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={cl("perms-list-item", { "perms-list-item-active": selectedItemIndex === index })}
|
className={cl("modal-list-item", { "modal-list-item-active": selectedItemIndex === index })}
|
||||||
onContextMenu={e => {
|
onContextMenu={e => {
|
||||||
if (permission.type === PermissionType.Role)
|
if (permission.type === PermissionType.Role)
|
||||||
ContextMenuApi.openContextMenu(e, () => (
|
ContextMenuApi.openContextMenu(e, () => (
|
||||||
|
@ -124,7 +129,6 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
ContextMenuApi.openContextMenu(e, () => (
|
ContextMenuApi.openContextMenu(e, () => (
|
||||||
<UserContextMenu
|
<UserContextMenu
|
||||||
userId={permission.id!}
|
userId={permission.id!}
|
||||||
onClose={modalProps.onClose}
|
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -132,13 +136,19 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
>
|
>
|
||||||
{(permission.type === PermissionType.Role || permission.type === PermissionType.Owner) && (
|
{(permission.type === PermissionType.Role || permission.type === PermissionType.Owner) && (
|
||||||
<span
|
<span
|
||||||
className={cl("perms-role-circle")}
|
className={cl("modal-role-circle")}
|
||||||
style={{ backgroundColor: role?.colorString ?? "var(--primary-300)" }}
|
style={{ backgroundColor: role?.colorString ?? "var(--primary-300)" }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{permission.type === PermissionType.User && user !== undefined && (
|
{permission.type === PermissionType.Role && roleIconSrc != null && (
|
||||||
<img
|
<img
|
||||||
className={cl("perms-user-img")}
|
className={cl("modal-role-image")}
|
||||||
|
src={roleIconSrc}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{permission.type === PermissionType.User && user != null && (
|
||||||
|
<img
|
||||||
|
className={cl("modal-user-img")}
|
||||||
src={user.getAvatarURL(void 0, void 0, false)}
|
src={user.getAvatarURL(void 0, void 0, false)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -147,28 +157,25 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
permission.type === PermissionType.Role
|
permission.type === PermissionType.Role
|
||||||
? role?.name ?? "Unknown Role"
|
? role?.name ?? "Unknown Role"
|
||||||
: permission.type === PermissionType.User
|
: permission.type === PermissionType.User
|
||||||
? (user && getUniqueUsername(user)) ?? "Unknown User"
|
? (user != null && getUniqueUsername(user)) ?? "Unknown User"
|
||||||
: (
|
: (
|
||||||
<Flex style={{ gap: "0.2em", justifyItems: "center" }}>
|
<Flex style={{ gap: "0.2em", justifyItems: "center" }}>
|
||||||
@owner
|
@owner
|
||||||
<OwnerCrownIcon
|
<OwnerCrownIcon height={18} width={18} aria-hidden="true" />
|
||||||
height={18}
|
|
||||||
width={18}
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</ScrollerThin>
|
||||||
<div className={cl("perms-perms")}>
|
<div className={cl("modal-divider")} />
|
||||||
|
<ScrollerThin className={cl("modal-perms")} orientation="auto">
|
||||||
{Object.entries(PermissionsBits).map(([permissionName, bit]) => (
|
{Object.entries(PermissionsBits).map(([permissionName, bit]) => (
|
||||||
<div className={cl("perms-perms-item")}>
|
<div className={cl("modal-perms-item")}>
|
||||||
<div className={cl("perms-perms-item-icon")}>
|
<div className={cl("modal-perms-item-icon")}>
|
||||||
{(() => {
|
{(() => {
|
||||||
const { permissions, overwriteAllow, overwriteDeny } = selectedItem;
|
const { permissions, overwriteAllow, overwriteDeny } = selectedItem;
|
||||||
|
|
||||||
|
@ -192,11 +199,11 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</ScrollerThin>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</ModalRoot >
|
</ModalRoot>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +215,7 @@ function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: str
|
||||||
aria-label="Role Options"
|
aria-label="Role Options"
|
||||||
>
|
>
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="vc-copy-role-id"
|
id={cl("copy-role-id")}
|
||||||
label={i18n.Messages.COPY_ID_ROLE}
|
label={i18n.Messages.COPY_ID_ROLE}
|
||||||
action={() => {
|
action={() => {
|
||||||
Clipboard.copy(roleId);
|
Clipboard.copy(roleId);
|
||||||
|
@ -217,14 +224,13 @@ function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: str
|
||||||
|
|
||||||
{(settings.store as any).unsafeViewAsRole && (
|
{(settings.store as any).unsafeViewAsRole && (
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="vc-pw-view-as-role"
|
id={cl("view-as-role")}
|
||||||
label={i18n.Messages.VIEW_AS_ROLE}
|
label={i18n.Messages.VIEW_AS_ROLE}
|
||||||
action={() => {
|
action={() => {
|
||||||
const role = GuildStore.getRole(guild.id, roleId);
|
const role = GuildStore.getRole(guild.id, roleId);
|
||||||
if (!role) return;
|
if (!role) return;
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
|
|
||||||
FluxDispatcher.dispatch({
|
FluxDispatcher.dispatch({
|
||||||
type: "IMPERSONATE_UPDATE",
|
type: "IMPERSONATE_UPDATE",
|
||||||
guildId: guild.id,
|
guildId: guild.id,
|
||||||
|
@ -235,15 +241,14 @@ function RoleContextMenu({ guild, roleId, onClose }: { guild: Guild; roleId: str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Menu.Menu>
|
</Menu.Menu>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserContextMenu({ userId, onClose }: { userId: string; onClose: () => void; }) {
|
function UserContextMenu({ userId }: { userId: string; }) {
|
||||||
return (
|
return (
|
||||||
<Menu.Menu
|
<Menu.Menu
|
||||||
navId={cl("user-context-menu")}
|
navId={cl("user-context-menu")}
|
||||||
|
@ -251,7 +256,7 @@ function UserContextMenu({ userId, onClose }: { userId: string; onClose: () => v
|
||||||
aria-label="User Options"
|
aria-label="User Options"
|
||||||
>
|
>
|
||||||
<Menu.MenuItem
|
<Menu.MenuItem
|
||||||
id="vc-copy-user-id"
|
id={cl("copy-user-id")}
|
||||||
label={i18n.Messages.COPY_ID_USER}
|
label={i18n.Messages.COPY_ID_USER}
|
||||||
action={() => {
|
action={() => {
|
||||||
Clipboard.copy(userId);
|
Clipboard.copy(userId);
|
||||||
|
@ -263,4 +268,13 @@ function UserContextMenu({ userId, onClose }: { userId: string; onClose: () => v
|
||||||
|
|
||||||
const RolesAndUsersPermissions = ErrorBoundary.wrap(RolesAndUsersPermissionsComponent);
|
const RolesAndUsersPermissions = ErrorBoundary.wrap(RolesAndUsersPermissionsComponent);
|
||||||
|
|
||||||
export default openRolesAndUsersPermissionsModal;
|
export default function openRolesAndUsersPermissionsModal(permissions: Array<RoleOrUserPermission>, guild: Guild, header: string) {
|
||||||
|
return openModal(modalProps => (
|
||||||
|
<RolesAndUsersPermissions
|
||||||
|
modalProps={modalProps}
|
||||||
|
permissions={permissions}
|
||||||
|
guild={guild}
|
||||||
|
header={header}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
|
@ -29,22 +29,65 @@ import openRolesAndUsersPermissionsModal, { PermissionType, type RoleOrUserPermi
|
||||||
|
|
||||||
interface UserPermission {
|
interface UserPermission {
|
||||||
permission: string;
|
permission: string;
|
||||||
|
roleName: string;
|
||||||
roleColor: string;
|
roleColor: string;
|
||||||
rolePosition: number;
|
rolePosition: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserPermissions = Array<UserPermission>;
|
type UserPermissions = Array<UserPermission>;
|
||||||
|
|
||||||
const Classes = proxyLazyWebpack(() =>
|
const { RoleRootClasses, RoleClasses, RoleBorderClasses } = proxyLazyWebpack(() => {
|
||||||
Object.assign({}, ...findBulk(
|
const [RoleRootClasses, RoleClasses, RoleBorderClasses] = findBulk(
|
||||||
filters.byProps("roles", "rolePill", "rolePillBorder"),
|
filters.byProps("root", "expandButton", "collapseButton"),
|
||||||
filters.byProps("roleCircle", "dotBorderBase", "dotBorderColor"),
|
filters.byProps("role", "roleCircle", "roleName"),
|
||||||
filters.byProps("roleNameOverflow", "root", "roleName", "roleRemoveButton")
|
filters.byProps("roleCircle", "dot", "dotBorderColor")
|
||||||
))
|
) as Record<string, string>[];
|
||||||
) as Record<"roles" | "rolePill" | "rolePillBorder" | "desaturateUserColors" | "flex" | "alignCenter" | "justifyCenter" | "svg" | "background" | "dot" | "dotBorderColor" | "roleCircle" | "dotBorderBase" | "flex" | "alignCenter" | "justifyCenter" | "wrap" | "root" | "role" | "roleRemoveButton" | "roleDot" | "roleFlowerStar" | "roleRemoveIcon" | "roleRemoveIconFocused" | "roleVerifiedIcon" | "roleName" | "roleNameOverflow" | "actionButton" | "overflowButton" | "addButton" | "addButtonIcon" | "overflowRolesPopout" | "overflowRolesPopoutArrowWrapper" | "overflowRolesPopoutArrow" | "popoutBottom" | "popoutTop" | "overflowRolesPopoutHeader" | "overflowRolesPopoutHeaderIcon" | "overflowRolesPopoutHeaderText" | "roleIcon", string>;
|
|
||||||
|
|
||||||
function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen = false }: { guild: Guild; guildMember: GuildMember; showBorder: boolean; forceOpen?: boolean; }) {
|
return { RoleRootClasses, RoleClasses, RoleBorderClasses };
|
||||||
const stns = settings.use(["permissionsSortOrder"]);
|
});
|
||||||
|
|
||||||
|
interface FakeRoleProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
text: string;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FakeRole({ text, color, ...props }: FakeRoleProps) {
|
||||||
|
return (
|
||||||
|
<div {...props} className={classes(RoleClasses.role)}>
|
||||||
|
<div className={RoleClasses.roleRemoveButton}>
|
||||||
|
<span
|
||||||
|
className={classes(RoleBorderClasses.roleCircle, RoleClasses.roleCircle)}
|
||||||
|
style={{ backgroundColor: color }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={RoleClasses.roleName}>
|
||||||
|
<Text
|
||||||
|
className={RoleClasses.roleNameOverflow}
|
||||||
|
variant="text-xs/medium"
|
||||||
|
>
|
||||||
|
{text}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GrantedByTooltipProps {
|
||||||
|
roleName: string;
|
||||||
|
roleColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function GrantedByTooltip({ roleName, roleColor }: GrantedByTooltipProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Text variant="text-sm/medium">Granted By</Text>
|
||||||
|
<FakeRole text={roleName} color={roleColor} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function UserPermissionsComponent({ guild, guildMember, forceOpen = false }: { guild: Guild; guildMember: GuildMember; forceOpen?: boolean; }) {
|
||||||
|
const { permissionsSortOrder } = settings.use(["permissionsSortOrder"]);
|
||||||
|
|
||||||
const [rolePermissions, userPermissions] = useMemo(() => {
|
const [rolePermissions, userPermissions] = useMemo(() => {
|
||||||
const userPermissions: UserPermissions = [];
|
const userPermissions: UserPermissions = [];
|
||||||
|
@ -65,6 +108,7 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
||||||
const OWNER = i18n.Messages.GUILD_OWNER || "Server Owner";
|
const OWNER = i18n.Messages.GUILD_OWNER || "Server Owner";
|
||||||
userPermissions.push({
|
userPermissions.push({
|
||||||
permission: OWNER,
|
permission: OWNER,
|
||||||
|
roleName: "Owner",
|
||||||
roleColor: "var(--primary-300)",
|
roleColor: "var(--primary-300)",
|
||||||
rolePosition: Infinity
|
rolePosition: Infinity
|
||||||
});
|
});
|
||||||
|
@ -73,10 +117,11 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
||||||
sortUserRoles(userRoles);
|
sortUserRoles(userRoles);
|
||||||
|
|
||||||
for (const [permission, bit] of Object.entries(PermissionsBits)) {
|
for (const [permission, bit] of Object.entries(PermissionsBits)) {
|
||||||
for (const { permissions, colorString, position } of userRoles) {
|
for (const { permissions, colorString, position, name } of userRoles) {
|
||||||
if ((permissions & bit) === bit) {
|
if ((permissions & bit) === bit) {
|
||||||
userPermissions.push({
|
userPermissions.push({
|
||||||
permission: getPermissionString(permission),
|
permission: getPermissionString(permission),
|
||||||
|
roleName: name,
|
||||||
roleColor: colorString || "var(--primary-300)",
|
roleColor: colorString || "var(--primary-300)",
|
||||||
rolePosition: position
|
rolePosition: position
|
||||||
});
|
});
|
||||||
|
@ -89,9 +134,7 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
||||||
userPermissions.sort((a, b) => b.rolePosition - a.rolePosition);
|
userPermissions.sort((a, b) => b.rolePosition - a.rolePosition);
|
||||||
|
|
||||||
return [rolePermissions, userPermissions];
|
return [rolePermissions, userPermissions];
|
||||||
}, [stns.permissionsSortOrder]);
|
}, [permissionsSortOrder]);
|
||||||
|
|
||||||
const { root, role, roleRemoveButton, roleNameOverflow, roles, rolePill, rolePillBorder, roleCircle, roleName } = Classes;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExpandableHeader
|
<ExpandableHeader
|
||||||
|
@ -108,46 +151,41 @@ function UserPermissionsComponent({ guild, guildMember, showBorder, forceOpen =
|
||||||
onDropDownClick={state => settings.store.defaultPermissionsDropdownState = !state}
|
onDropDownClick={state => settings.store.defaultPermissionsDropdownState = !state}
|
||||||
defaultState={settings.store.defaultPermissionsDropdownState}
|
defaultState={settings.store.defaultPermissionsDropdownState}
|
||||||
buttons={[
|
buttons={[
|
||||||
(<Tooltip text={`Sorting by ${stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? "Highest Role" : "Lowest Role"}`}>
|
<Tooltip text={`Sorting by ${permissionsSortOrder === PermissionsSortOrder.HighestRole ? "Highest Role" : "Lowest Role"}`}>
|
||||||
{tooltipProps => (
|
{tooltipProps => (
|
||||||
<button
|
<div
|
||||||
{...tooltipProps}
|
{...tooltipProps}
|
||||||
className={cl("userperms-sortorder-btn")}
|
className={cl("user-sortorder-btn")}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
stns.permissionsSortOrder = stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? PermissionsSortOrder.LowestRole : PermissionsSortOrder.HighestRole;
|
settings.store.permissionsSortOrder = permissionsSortOrder === PermissionsSortOrder.HighestRole ? PermissionsSortOrder.LowestRole : PermissionsSortOrder.HighestRole;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
width="20"
|
width="20"
|
||||||
height="20"
|
height="20"
|
||||||
viewBox="0 96 960 960"
|
viewBox="0 96 960 960"
|
||||||
transform={stns.permissionsSortOrder === PermissionsSortOrder.HighestRole ? "scale(1 1)" : "scale(1 -1)"}
|
transform={permissionsSortOrder === PermissionsSortOrder.HighestRole ? "scale(1 1)" : "scale(1 -1)"}
|
||||||
>
|
>
|
||||||
<path fill="var(--text-normal)" d="M440 896V409L216 633l-56-57 320-320 320 320-56 57-224-224v487h-80Z" />
|
<path fill="var(--text-normal)" d="M440 896V409L216 633l-56-57 320-320 320 320-56 57-224-224v487h-80Z" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Tooltip>)
|
</Tooltip>
|
||||||
]}>
|
]}>
|
||||||
{userPermissions.length > 0 && (
|
{userPermissions.length > 0 && (
|
||||||
<div className={classes(root, roles)}>
|
<div className={classes(RoleRootClasses.root)}>
|
||||||
{userPermissions.map(({ permission, roleColor }) => (
|
{userPermissions.map(({ permission, roleColor, roleName }) => (
|
||||||
<div className={classes(role, rolePill, showBorder ? rolePillBorder : null)}>
|
<Tooltip
|
||||||
<div className={roleRemoveButton}>
|
text={<GrantedByTooltip roleName={roleName} roleColor={roleColor} />}
|
||||||
<span
|
tooltipClassName={cl("granted-by-container")}
|
||||||
className={roleCircle}
|
tooltipContentClassName={cl("granted-by-content")}
|
||||||
style={{ backgroundColor: roleColor }}
|
>
|
||||||
/>
|
{tooltipProps => (
|
||||||
</div>
|
<FakeRole {...tooltipProps} text={permission} color={roleColor} />
|
||||||
<div className={roleName}>
|
)}
|
||||||
<Text
|
</Tooltip>
|
||||||
className={roleNameOverflow}
|
|
||||||
variant="text-xs/medium"
|
|
||||||
>
|
|
||||||
{permission}
|
|
||||||
</Text>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Button, ChannelStore, Dialog, GuildMemberStore, GuildStore, Menu, PermissionsBits, Popout, TooltipContainer, UserStore } from "@webpack/common";
|
import { Button, ChannelStore, Dialog, GuildMemberStore, GuildStore, match, Menu, PermissionsBits, Popout, TooltipContainer, UserStore } from "@webpack/common";
|
||||||
import type { Guild, GuildMember } from "discord-types/general";
|
import type { Guild, GuildMember } from "discord-types/general";
|
||||||
|
|
||||||
import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "./components/RolesAndUsersPermissions";
|
import openRolesAndUsersPermissionsModal, { PermissionType, RoleOrUserPermission } from "./components/RolesAndUsersPermissions";
|
||||||
|
@ -54,12 +54,12 @@ export const settings = definePluginSettings({
|
||||||
options: [
|
options: [
|
||||||
{ label: "Highest Role", value: PermissionsSortOrder.HighestRole, default: true },
|
{ label: "Highest Role", value: PermissionsSortOrder.HighestRole, default: true },
|
||||||
{ label: "Lowest Role", value: PermissionsSortOrder.LowestRole }
|
{ label: "Lowest Role", value: PermissionsSortOrder.LowestRole }
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
defaultPermissionsDropdownState: {
|
defaultPermissionsDropdownState: {
|
||||||
description: "Whether the permissions dropdown on user popouts should be open by default",
|
description: "Whether the permissions dropdown on user popouts should be open by default",
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
default: false,
|
default: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,14 +73,12 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
action={() => {
|
action={() => {
|
||||||
const guild = GuildStore.getGuild(guildId);
|
const guild = GuildStore.getGuild(guildId);
|
||||||
|
|
||||||
let permissions: RoleOrUserPermission[];
|
const { permissions, header } = match(type)
|
||||||
let header: string;
|
.returnType<{ permissions: RoleOrUserPermission[], header: string; }>()
|
||||||
|
.with(MenuItemParentType.User, () => {
|
||||||
switch (type) {
|
|
||||||
case MenuItemParentType.User: {
|
|
||||||
const member = GuildMemberStore.getMember(guildId, id!);
|
const member = GuildMemberStore.getMember(guildId, id!);
|
||||||
|
|
||||||
permissions = getSortedRoles(guild, member)
|
const permissions: RoleOrUserPermission[] = getSortedRoles(guild, member)
|
||||||
.map(role => ({
|
.map(role => ({
|
||||||
type: PermissionType.Role,
|
type: PermissionType.Role,
|
||||||
...role
|
...role
|
||||||
|
@ -93,37 +91,37 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
header = member.nick ?? UserStore.getUser(member.userId).username;
|
return {
|
||||||
|
permissions,
|
||||||
break;
|
header: member.nick ?? UserStore.getUser(member.userId).username
|
||||||
}
|
};
|
||||||
|
})
|
||||||
case MenuItemParentType.Channel: {
|
.with(MenuItemParentType.Channel, () => {
|
||||||
const channel = ChannelStore.getChannel(id!);
|
const channel = ChannelStore.getChannel(id!);
|
||||||
|
|
||||||
permissions = sortPermissionOverwrites(Object.values(channel.permissionOverwrites).map(({ id, allow, deny, type }) => ({
|
const permissions = sortPermissionOverwrites(Object.values(channel.permissionOverwrites).map(({ id, allow, deny, type }) => ({
|
||||||
type: type as PermissionType,
|
type: type as PermissionType,
|
||||||
id,
|
id,
|
||||||
overwriteAllow: allow,
|
overwriteAllow: allow,
|
||||||
overwriteDeny: deny
|
overwriteDeny: deny
|
||||||
})), guildId);
|
})), guildId);
|
||||||
|
|
||||||
header = channel.name;
|
return {
|
||||||
|
permissions,
|
||||||
break;
|
header: channel.name
|
||||||
}
|
};
|
||||||
|
})
|
||||||
default: {
|
.otherwise(() => {
|
||||||
permissions = Object.values(GuildStore.getRoles(guild.id)).map(role => ({
|
const permissions = Object.values(GuildStore.getRoles(guild.id)).map(role => ({
|
||||||
type: PermissionType.Role,
|
type: PermissionType.Role,
|
||||||
...role
|
...role
|
||||||
}));
|
}));
|
||||||
|
|
||||||
header = guild.name;
|
return {
|
||||||
|
permissions,
|
||||||
break;
|
header: guild.name
|
||||||
}
|
};
|
||||||
}
|
});
|
||||||
|
|
||||||
openRolesAndUsersPermissionsModal(permissions, guild, header);
|
openRolesAndUsersPermissionsModal(permissions, guild, header);
|
||||||
}}
|
}}
|
||||||
|
@ -133,32 +131,34 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
|
|
||||||
function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
|
function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback {
|
||||||
return (children, props) => {
|
return (children, props) => {
|
||||||
if (!props) return;
|
if (
|
||||||
if ((type === MenuItemParentType.User && !props.user) || (type === MenuItemParentType.Guild && !props.guild) || (type === MenuItemParentType.Channel && (!props.channel || !props.guild)))
|
!props ||
|
||||||
|
(type === MenuItemParentType.User && !props.user) ||
|
||||||
|
(type === MenuItemParentType.Guild && !props.guild) ||
|
||||||
|
(type === MenuItemParentType.Channel && (!props.channel || !props.guild))
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const group = findGroupChildrenByChildId(childId, children);
|
const group = findGroupChildrenByChildId(childId, children);
|
||||||
|
|
||||||
const item = (() => {
|
const item = match(type)
|
||||||
switch (type) {
|
.with(MenuItemParentType.User, () => MenuItem(props.guildId, props.user.id, type))
|
||||||
case MenuItemParentType.User:
|
.with(MenuItemParentType.Channel, () => MenuItem(props.guild.id, props.channel.id, type))
|
||||||
return MenuItem(props.guildId, props.user.id, type);
|
.with(MenuItemParentType.Guild, () => MenuItem(props.guild.id))
|
||||||
case MenuItemParentType.Channel:
|
.otherwise(() => null);
|
||||||
return MenuItem(props.guild.id, props.channel.id, type);
|
|
||||||
case MenuItemParentType.Guild:
|
|
||||||
return MenuItem(props.guild.id);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
if (group)
|
if (group) {
|
||||||
group.push(item);
|
return group.push(item);
|
||||||
else if (childId === "roles" && props.guildId)
|
}
|
||||||
// "roles" may not be present due to the member not having any roles. In that case, add it above "Copy ID"
|
|
||||||
|
// "roles" may not be present due to the member not having any roles. In that case, add it above "Copy ID"
|
||||||
|
if (childId === "roles" && props.guildId) {
|
||||||
children.splice(-1, 0, <Menu.MenuGroup>{item}</Menu.MenuGroup>);
|
children.splice(-1, 0, <Menu.MenuGroup>{item}</Menu.MenuGroup>);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,32 +169,22 @@ export default definePlugin({
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
|
||||||
find: ".popularApplicationCommandIds,",
|
|
||||||
replacement: {
|
|
||||||
match: /showBorder:(.{0,60})}\),(?<=guild:(\i),guildMember:(\i),.+?)/,
|
|
||||||
replace: (m, showBoder, guild, guildMember) => `${m}$self.UserPermissions(${guild},${guildMember},${showBoder}),`
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: ".VIEW_ALL_ROLES,",
|
find: ".VIEW_ALL_ROLES,",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /children:"\+"\.concat\(\i\.length-\i\.length\).{0,20}\}\),/,
|
match: /\.expandButton,.+?null,/,
|
||||||
replace: "$&$self.ViewPermissionsButton(arguments[0]),"
|
replace: "$&$self.ViewPermissionsButton(arguments[0]),"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
UserPermissions: (guild: Guild, guildMember: GuildMember | undefined, showBorder: boolean) =>
|
|
||||||
!!guildMember && <UserPermissions guild={guild} guildMember={guildMember} showBorder={showBorder} />,
|
|
||||||
|
|
||||||
ViewPermissionsButton: ErrorBoundary.wrap(({ guild, guildMember }: { guild: Guild; guildMember: GuildMember; }) => (
|
ViewPermissionsButton: ErrorBoundary.wrap(({ guild, guildMember }: { guild: Guild; guildMember: GuildMember; }) => (
|
||||||
<Popout
|
<Popout
|
||||||
position="bottom"
|
position="bottom"
|
||||||
align="center"
|
align="center"
|
||||||
renderPopout={() => (
|
renderPopout={() => (
|
||||||
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
||||||
<UserPermissions guild={guild} guildMember={guildMember} showBorder forceOpen />
|
<UserPermissions guild={guild} guildMember={guildMember} forceOpen />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,20 +1,6 @@
|
||||||
/* User Permissions Component */
|
/* User Permissions Component */
|
||||||
|
|
||||||
.vc-permviewer-userperms-title-container {
|
.vc-permviewer-user-sortorder-btn {
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-top: 10px;
|
|
||||||
margin-bottom: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-permviewer-userperms-btns-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-permviewer-userperms-sortorder-btn {
|
|
||||||
all: unset;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -23,27 +9,17 @@
|
||||||
height: 24px;
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-userperms-permdetails-btn {
|
|
||||||
all: unset;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-permviewer-userperms-toggleperms-btn {
|
|
||||||
all: unset;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RolesAndUsersPermissions Component */
|
/* RolesAndUsersPermissions Component */
|
||||||
|
|
||||||
.vc-permviewer-perms-title {
|
.vc-permviewer-modal-content {
|
||||||
|
padding: 16px 4px 16px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-modal-title {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-no-perms {
|
.vc-permviewer-modal-no-perms {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -52,101 +28,103 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-container {
|
.vc-permviewer-modal-container {
|
||||||
display: grid;
|
width: 100%;
|
||||||
grid-template-columns: 1fr 2fr;
|
height: 100%;
|
||||||
grid-template-areas: "list permissions";
|
display: flex;
|
||||||
padding: 16px 0;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list {
|
.vc-permviewer-modal-list {
|
||||||
grid-area: list;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
border-right: 2px solid var(--background-modifier-active);
|
padding-right: 8px;
|
||||||
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list-item-btn {
|
.vc-permviewer-modal-list-item-btn {
|
||||||
all: unset;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list-item {
|
.vc-permviewer-modal-list-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 8px 5px;
|
gap: 8px;
|
||||||
cursor: pointer;
|
padding: 8px;
|
||||||
width: 230px;
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list-item:hover {
|
.vc-permviewer-modal-list-item:hover {
|
||||||
background-color: var(--background-modifier-hover);
|
background-color: var(--background-modifier-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list-item-active {
|
.vc-permviewer-modal-list-item-active {
|
||||||
background-color: var(--background-modifier-selected);
|
background-color: var(--background-modifier-selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-list-item > div {
|
.vc-permviewer-modal-list-item > div {
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-role-circle {
|
.vc-permviewer-modal-role-circle {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 12px;
|
width: 12px;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
margin-left: 3px;
|
|
||||||
margin-right: 11px;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-user-img {
|
.vc-permviewer-modal-role-image {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-modal-user-img {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
margin-right: 6px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms {
|
.vc-permviewer-modal-divider {
|
||||||
grid-area: permissions;
|
width: 2px;
|
||||||
|
background-color: var(--background-modifier-active);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-modal-perms {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin-left: 5px;
|
padding-right: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms-item {
|
.vc-permviewer-modal-perms-item {
|
||||||
position: relative;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 10px;
|
gap: 5px;
|
||||||
|
padding: 10px 2px 10px 10px;
|
||||||
border-bottom: 2px solid var(--background-modifier-active);
|
border-bottom: 2px solid var(--background-modifier-active);
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms-item:last-child {
|
.vc-permviewer-modal-perms-item:last-child {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms-item-icon {
|
.vc-permviewer-modal-perms-item-icon {
|
||||||
border: 1px solid var(--background-modifier-selected);
|
border: 1px solid var(--background-modifier-selected);
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
margin-right: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms-item .vc-info-icon {
|
.vc-permviewer-modal-perms-item .vc-info-icon {
|
||||||
color: var(--interactive-muted);
|
color: var(--interactive-muted);
|
||||||
|
margin-left: auto;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
scale: 0.9;
|
|
||||||
transition: color ease-in 0.1s;
|
transition: color ease-in 0.1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-permviewer-perms-perms-item .vc-info-icon:hover {
|
.vc-permviewer-modal-perms-item .vc-info-icon:hover {
|
||||||
color: var(--interactive-active);
|
color: var(--interactive-active);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,3 +145,14 @@
|
||||||
background: rgb(var(--bg-overlay-color)/var(--bg-overlay-opacity-6));
|
background: rgb(var(--bg-overlay-color)/var(--bg-overlay-opacity-6));
|
||||||
border-color: var(--profile-body-border-color)
|
border-color: var(--profile-body-border-color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-granted-by-container {
|
||||||
|
max-width: 300px;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-permviewer-granted-by-content {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
|
@ -88,7 +88,6 @@ export default definePlugin({
|
||||||
name: "petpet",
|
name: "petpet",
|
||||||
description: "Adds a /petpet slash command to create headpet gifs from any image",
|
description: "Adds a /petpet slash command to create headpet gifs from any image",
|
||||||
authors: [Devs.Ven],
|
authors: [Devs.Ven],
|
||||||
dependencies: ["CommandsAPI"],
|
|
||||||
commands: [
|
commands: [
|
||||||
{
|
{
|
||||||
inputType: ApplicationCommandInputType.BUILT_IN,
|
inputType: ApplicationCommandInputType.BUILT_IN,
|
||||||
|
|
|
@ -24,13 +24,13 @@ const settings = definePluginSettings({
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "PictureInPicture",
|
name: "PictureInPicture",
|
||||||
description: "Adds picture in picture to videos (next to the Download button)",
|
description: "Adds picture in picture to videos (next to the Download button)",
|
||||||
authors: [Devs.Nobody],
|
authors: [Devs.Lumap],
|
||||||
settings,
|
settings,
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: ".nonMediaMosaicItem]",
|
find: ".removeMosaicItemHoverButton),",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.nonMediaMosaicItem\]:!(\i).{0,50}?children:\[(\S)/,
|
match: /\.nonMediaMosaicItem\]:!(\i).{0,50}?children:\[\S,(\S)/,
|
||||||
replace: "$&,$1&&$2&&$self.renderPiPButton(),"
|
replace: "$&,$1&&$2&&$self.renderPiPButton(),"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue