Compare commits
6 commits
f33e0dcb73
...
06ceb4b82c
Author | SHA1 | Date | |
---|---|---|---|
06ceb4b82c | |||
4a77c885dd | |||
7d696f6b71 | |||
bf758167d6 | |||
a0e1e46765 | |||
5578cef24d |
37 changed files with 391 additions and 287 deletions
|
@ -31,7 +31,6 @@ Before starting your plugin:
|
||||||
- No FakeDeafen or FakeMute
|
- No FakeDeafen or FakeMute
|
||||||
- No StereoMic
|
- No StereoMic
|
||||||
- No plugins that simply hide or redesign ui elements. This can be done with CSS
|
- No plugins that simply hide or redesign ui elements. This can be done with CSS
|
||||||
- No plugins that interact with specific Discord bots (official Discord apps like Youtube WatchTogether are okay)
|
|
||||||
- No selfbots or API spam (animated status, message pruner, auto reply, nitro snipers, etc)
|
- No selfbots or API spam (animated status, message pruner, auto reply, nitro snipers, etc)
|
||||||
- No untrusted third party APIs. Popular services like Google or GitHub are fine, but absolutely no self hosted ones
|
- No untrusted third party APIs. Popular services like Google or GitHub are fine, but absolutely no self hosted ones
|
||||||
- No plugins that require the user to enter their own API key
|
- No plugins that require the user to enter their own API key
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vencord",
|
"name": "vencord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.10.8",
|
"version": "1.10.7",
|
||||||
"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": {
|
||||||
|
|
|
@ -99,8 +99,7 @@ export interface ChatBarButtonProps {
|
||||||
tooltip: string;
|
tooltip: string;
|
||||||
onClick: MouseEventHandler<HTMLButtonElement>;
|
onClick: MouseEventHandler<HTMLButtonElement>;
|
||||||
onContextMenu?: MouseEventHandler<HTMLButtonElement>;
|
onContextMenu?: MouseEventHandler<HTMLButtonElement>;
|
||||||
onAuxClick?: MouseEventHandler<HTMLButtonElement>;
|
buttonProps?: Omit<HTMLProps<HTMLButtonElement>, "size" | "onClick" | "onContextMenu">;
|
||||||
buttonProps?: Omit<HTMLProps<HTMLButtonElement>, "size" | "onClick" | "onContextMenu" | "onAuxClick">;
|
|
||||||
}
|
}
|
||||||
export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {
|
export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {
|
||||||
return (
|
return (
|
||||||
|
@ -116,7 +115,6 @@ export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {
|
||||||
innerClassName={`${ButtonWrapperClasses.button} ${ChannelTextAreaClasses?.button}`}
|
innerClassName={`${ButtonWrapperClasses.button} ${ChannelTextAreaClasses?.button}`}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
onContextMenu={props.onContextMenu}
|
onContextMenu={props.onContextMenu}
|
||||||
onAuxClick={props.onAuxClick}
|
|
||||||
{...props.buttonProps}
|
{...props.buttonProps}
|
||||||
>
|
>
|
||||||
<div className={ButtonWrapperClasses.buttonWrapper}>
|
<div className={ButtonWrapperClasses.buttonWrapper}>
|
||||||
|
|
|
@ -54,5 +54,5 @@ export function sendBotMessage(channelId: string, message: PartialDeep<Message>)
|
||||||
export function findOption<T>(args: Argument[], name: string): T & {} | undefined;
|
export function findOption<T>(args: Argument[], name: string): T & {} | undefined;
|
||||||
export function findOption<T>(args: Argument[], name: string, fallbackValue: T): T & {};
|
export function findOption<T>(args: Argument[], name: string, fallbackValue: T): T & {};
|
||||||
export function findOption(args: Argument[], name: string, fallbackValue?: any) {
|
export function findOption(args: Argument[], name: string, fallbackValue?: any) {
|
||||||
return (args.find(a => a.name === name)?.value ?? fallbackValue) as any;
|
return (args.find(a => a.name === name)?.value || fallbackValue) as any;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,6 @@ function registerSubCommands(cmd: Command, plugin: string) {
|
||||||
const subCmd = {
|
const subCmd = {
|
||||||
...cmd,
|
...cmd,
|
||||||
...o,
|
...o,
|
||||||
options: o.options !== undefined ? o.options : undefined,
|
|
||||||
type: ApplicationCommandType.CHAT_INPUT,
|
type: ApplicationCommandType.CHAT_INPUT,
|
||||||
name: `${cmd.name} ${o.name}`,
|
name: `${cmd.name} ${o.name}`,
|
||||||
id: `${o.name}-${cmd.id}`,
|
id: `${o.name}-${cmd.id}`,
|
||||||
|
|
11
src/components/ExpandableHeader.css
Normal file
11
src/components/ExpandableHeader.css
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
.vc-expandableheader-center-flex {
|
||||||
|
display: flex;
|
||||||
|
place-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-expandableheader-btn {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
121
src/components/ExpandableHeader.tsx
Normal file
121
src/components/ExpandableHeader.tsx
Normal file
|
@ -0,0 +1,121 @@
|
||||||
|
/*
|
||||||
|
* 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 "./ExpandableHeader.css";
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import { Text, Tooltip, useState } from "@webpack/common";
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-expandableheader-");
|
||||||
|
|
||||||
|
export interface ExpandableHeaderProps {
|
||||||
|
onMoreClick?: () => void;
|
||||||
|
moreTooltipText?: string;
|
||||||
|
onDropDownClick?: (state: boolean) => void;
|
||||||
|
defaultState?: boolean;
|
||||||
|
headerText: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
buttons?: React.ReactNode[];
|
||||||
|
forceOpen?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ExpandableHeader({
|
||||||
|
children,
|
||||||
|
onMoreClick,
|
||||||
|
buttons,
|
||||||
|
moreTooltipText,
|
||||||
|
onDropDownClick,
|
||||||
|
headerText,
|
||||||
|
defaultState = false,
|
||||||
|
forceOpen = false,
|
||||||
|
}: ExpandableHeaderProps) {
|
||||||
|
const [showContent, setShowContent] = useState(defaultState || forceOpen);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
alignItems: "center",
|
||||||
|
marginBottom: "8px"
|
||||||
|
}}>
|
||||||
|
<Text
|
||||||
|
tag="h2"
|
||||||
|
variant="eyebrow"
|
||||||
|
style={{
|
||||||
|
color: "var(--header-primary)",
|
||||||
|
display: "inline"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{headerText}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<div className={cl("center-flex")}>
|
||||||
|
{
|
||||||
|
buttons ?? null
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
onMoreClick && // only show more button if callback is provided
|
||||||
|
<Tooltip text={moreTooltipText}>
|
||||||
|
{tooltipProps => (
|
||||||
|
<button
|
||||||
|
{...tooltipProps}
|
||||||
|
className={cl("btn")}
|
||||||
|
onClick={onMoreClick}>
|
||||||
|
<svg
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path fill="var(--text-normal)" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<Tooltip text={showContent ? "Hide " + headerText : "Show " + headerText}>
|
||||||
|
{tooltipProps => (
|
||||||
|
<button
|
||||||
|
{...tooltipProps}
|
||||||
|
className={cl("btn")}
|
||||||
|
onClick={() => {
|
||||||
|
setShowContent(v => !v);
|
||||||
|
onDropDownClick?.(showContent);
|
||||||
|
}}
|
||||||
|
disabled={forceOpen}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
width="24"
|
||||||
|
height="24"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
transform={showContent ? "scale(1 -1)" : "scale(1 1)"}
|
||||||
|
>
|
||||||
|
<path fill="var(--text-normal)" d="M16.59 8.59003L12 13.17L7.41 8.59003L6 10L12 16L18 10L16.59 8.59003Z" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{showContent && children}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ export * from "./CodeBlock";
|
||||||
export * from "./DonateButton";
|
export * from "./DonateButton";
|
||||||
export { default as ErrorBoundary } from "./ErrorBoundary";
|
export { default as ErrorBoundary } from "./ErrorBoundary";
|
||||||
export * from "./ErrorCard";
|
export * from "./ErrorCard";
|
||||||
|
export * from "./ExpandableHeader";
|
||||||
export * from "./Flex";
|
export * from "./Flex";
|
||||||
export * from "./Heart";
|
export * from "./Heart";
|
||||||
export * from "./Icons";
|
export * from "./Icons";
|
||||||
|
|
|
@ -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,5 +0,0 @@
|
||||||
/* the profile popout badge container(s) */
|
|
||||||
[class*="biteSize_"] [class*="tags_"] [class*="container_"] {
|
|
||||||
/* Discord has padding set to 2px instead of 1px, which causes the 12th badge to wrap to a new line. */
|
|
||||||
padding: 0 1px;
|
|
||||||
}
|
|
|
@ -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 "./fixDiscordBadgePadding.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";
|
||||||
|
|
|
@ -23,14 +23,11 @@ export default definePlugin({
|
||||||
name: "MessagePopoverAPI",
|
name: "MessagePopoverAPI",
|
||||||
description: "API to add buttons to message popovers.",
|
description: "API to add buttons to message popovers.",
|
||||||
authors: [Devs.KingFish, Devs.Ven, Devs.Nuckyz],
|
authors: [Devs.KingFish, Devs.Ven, Devs.Nuckyz],
|
||||||
patches: [
|
patches: [{
|
||||||
{
|
find: "#{intl::MESSAGE_UTILITIES_A11Y_LABEL}",
|
||||||
find: "#{intl::MESSAGE_UTILITIES_A11Y_LABEL}",
|
replacement: {
|
||||||
replacement: {
|
match: /\.jsx\)\((\i\.\i),\{label:\i\.\i\.string\(\i\.\i#{intl::MESSAGE_ACTION_REPLY}.{0,200}?"reply-self".{0,50}?\}\):null(?=,.+?message:(\i))/,
|
||||||
match: /(?<=:null),(.{0,40}togglePopout:.+?}\))\]}\):null,(?<=\((\i\.\i),{label:.+?:null,(\i&&!\i)\?\(0,\i\.jsxs?\)\(\i\.Fragment.+?message:(\i).+?)/,
|
replace: "$&,Vencord.Api.MessagePopover._buildPopoverElements($1,$2)"
|
||||||
replace: (_, ReactButton, ButtonComponent, showReactButton, message) => "" +
|
|
||||||
`]}):null,Vencord.Api.MessagePopover._buildPopoverElements(${ButtonComponent},${message}),${showReactButton}?${ReactButton}:null,`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}],
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "bitbucket.org",
|
find: "bitbucket.org",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /function \i\(\i\){(?=.{0,30}pathname:\i)/,
|
match: /function \i\(\i\){(?=.{0,60}\.parse\(\i\))/,
|
||||||
replace: "$&return null;"
|
replace: "$&return null;"
|
||||||
},
|
},
|
||||||
predicate: () => settings.store.file
|
predicate: () => settings.store.file
|
||||||
|
|
|
@ -123,7 +123,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
// 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\].+?}\)\](?=}\))/,
|
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
|
||||||
|
@ -159,7 +159,7 @@ export default definePlugin({
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".expandedFolderBackground,",
|
find: ".FOLDER_ITEM_GUILD_ICON_MARGIN);",
|
||||||
predicate: () => settings.store.sidebar,
|
predicate: () => settings.store.sidebar,
|
||||||
replacement: [
|
replacement: [
|
||||||
// We use arguments[0] to access the isBetterFolders variable in this nested folder component (the parent exports all the props so we don't have to patch it)
|
// We use arguments[0] to access the isBetterFolders variable in this nested folder component (the parent exports all the props so we don't have to patch it)
|
||||||
|
@ -185,7 +185,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
// 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: /(?<=\.isExpanded\),children:\[)/,
|
match: /(?<=\.wrapper,children:\[)/,
|
||||||
replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&"
|
replace: "$self.shouldShowFolderIconAndBackground(!!arguments[0]?.isBetterFolders,arguments[0]?.betterFoldersExpandedIds)&&"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -275,30 +275,24 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
|
makeGuildsBarGuildListFilter(isBetterFolders: boolean) {
|
||||||
return child => {
|
return child => {
|
||||||
if (!isBetterFolders) return true;
|
if (isBetterFolders) {
|
||||||
|
try {
|
||||||
try {
|
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
|
||||||
return child?.props?.["aria-label"] === getIntlMessage("SERVERS");
|
} catch (e) {
|
||||||
} catch (e) {
|
console.error(e);
|
||||||
console.error(e);
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return true;
|
};
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
makeGuildsBarTreeFilter(isBetterFolders: boolean) {
|
makeGuildsBarTreeFilter(isBetterFolders: boolean) {
|
||||||
return child => {
|
return child => {
|
||||||
if (!isBetterFolders) return true;
|
if (isBetterFolders) {
|
||||||
|
return child?.props?.onScroll != null;
|
||||||
if (child?.props?.className?.includes("itemsContainer") && child.props.children != null) {
|
|
||||||
// Filter out everything but the scroller for the guild list
|
|
||||||
child.props.children = child.props.children.filter(child => child?.props?.onScroll != null);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -75,11 +75,10 @@ export default definePlugin({
|
||||||
patches: [{
|
patches: [{
|
||||||
find: "renderConnectionStatus(){",
|
find: "renderConnectionStatus(){",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=renderConnectionStatus\(\){.+\.channel,children:).+?}\):\i(?=}\))/,
|
match: /(?<=renderConnectionStatus\(\)\{.+\.channel,children:)\i/,
|
||||||
replace: "[$&, $self.renderTimer(this.props.channel.id)]"
|
replace: "[$&, $self.renderTimer(this.props.channel.id)]"
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
renderTimer(channelId: string) {
|
renderTimer(channelId: string) {
|
||||||
return <ErrorBoundary noop>
|
return <ErrorBoundary noop>
|
||||||
<this.Timer channelId={channelId} />
|
<this.Timer channelId={channelId} />
|
||||||
|
|
|
@ -66,13 +66,6 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
|
||||||
find: "https://github.com/highlightjs/highlight.js/issues/2277",
|
|
||||||
replacement: {
|
|
||||||
match: /(?<=&&\()console.log\(`Deprecated.+?`\),/,
|
|
||||||
replace: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: 'react-spring: The "interpolate" function',
|
find: 'react-spring: The "interpolate" function',
|
||||||
replacement: {
|
replacement: {
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
* 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("DisableCallIdle", "DisableDMCallIdle");
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "DisableCallIdle",
|
name: "DisableCallIdle",
|
||||||
description: "Disables automatically getting kicked from a DM voice call after 3 minutes and being moved to an AFK voice channel.",
|
description: "Disables automatically getting kicked from a DM voice call after 3 minutes and being moved to an AFK voice channel.",
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { FluxDispatcher, useLayoutEffect, useRef, useState } from "@webpack/common";
|
import { FluxDispatcher, React, useRef, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { ELEMENT_ID } from "../constants";
|
import { ELEMENT_ID } from "../constants";
|
||||||
import { settings } from "../index";
|
import { settings } from "../index";
|
||||||
|
@ -55,7 +55,7 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
|
||||||
const imageRef = useRef<HTMLImageElement | null>(null);
|
const imageRef = useRef<HTMLImageElement | null>(null);
|
||||||
|
|
||||||
// since we accessing document im gonna use useLayoutEffect
|
// since we accessing document im gonna use useLayoutEffect
|
||||||
useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
const onKeyDown = (e: KeyboardEvent) => {
|
const onKeyDown = (e: KeyboardEvent) => {
|
||||||
if (e.key === "Shift") {
|
if (e.key === "Shift") {
|
||||||
isShiftDown.current = true;
|
isShiftDown.current = true;
|
||||||
|
@ -135,14 +135,12 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
|
||||||
|
|
||||||
setReady(true);
|
setReady(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("keydown", onKeyDown);
|
document.addEventListener("keydown", onKeyDown);
|
||||||
document.addEventListener("keyup", onKeyUp);
|
document.addEventListener("keyup", onKeyUp);
|
||||||
document.addEventListener("mousemove", updateMousePosition);
|
document.addEventListener("mousemove", updateMousePosition);
|
||||||
document.addEventListener("mousedown", onMouseDown);
|
document.addEventListener("mousedown", onMouseDown);
|
||||||
document.addEventListener("mouseup", onMouseUp);
|
document.addEventListener("mouseup", onMouseUp);
|
||||||
document.addEventListener("wheel", onWheel);
|
document.addEventListener("wheel", onWheel);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener("keydown", onKeyDown);
|
document.removeEventListener("keydown", onKeyDown);
|
||||||
document.removeEventListener("keyup", onKeyUp);
|
document.removeEventListener("keyup", onKeyUp);
|
||||||
|
@ -150,16 +148,14 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
|
||||||
document.removeEventListener("mousedown", onMouseDown);
|
document.removeEventListener("mousedown", onMouseDown);
|
||||||
document.removeEventListener("mouseup", onMouseUp);
|
document.removeEventListener("mouseup", onMouseUp);
|
||||||
document.removeEventListener("wheel", onWheel);
|
document.removeEventListener("wheel", onWheel);
|
||||||
|
|
||||||
|
if (settings.store.saveZoomValues) {
|
||||||
|
settings.store.zoom = zoom.current;
|
||||||
|
settings.store.size = size.current;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useLayoutEffect(() => () => {
|
|
||||||
if (settings.store.saveZoomValues) {
|
|
||||||
settings.store.zoom = zoom.current;
|
|
||||||
settings.store.size = size.current;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!ready) return null;
|
if (!ready) return null;
|
||||||
|
|
||||||
const box = element.current?.getBoundingClientRect();
|
const box = element.current?.getBoundingClientRect();
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
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 { Logger } from "@utils/Logger";
|
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||||
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, useMemo, UserStore } from "@webpack/common";
|
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, useMemo, UserStore } from "@webpack/common";
|
||||||
|
@ -88,7 +87,7 @@ export default definePlugin({
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /\i\.useEffect.{0,100}(\i)\[0\]\.section/,
|
match: /\i\.useEffect.{0,100}(\i)\[0\]\.section/,
|
||||||
replace: "$self.pushSection($1,arguments[0].user);$&"
|
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)/,
|
||||||
|
@ -98,46 +97,26 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: 'section:"MUTUAL_FRIENDS"',
|
find: 'section:"MUTUAL_FRIENDS"',
|
||||||
replacement: [
|
replacement: {
|
||||||
{
|
match: /\.openUserProfileModal.+?\)}\)}\)(?<=(\(0,\i\.jsxs?\)\(\i\.\i,{className:(\i)\.divider}\)).+?)/,
|
||||||
match: /\i\|\|\i(?=\?\(0,\i\.jsxs?\)\(\i\.\i\.Overlay,)/,
|
replace: "$&,$self.renderDMPageList({user: arguments[0].user, Divider: $1, listStyle: $2.list})"
|
||||||
replace: "$&||$self.getMutualGroupDms(arguments[0].user.id).length>0"
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
match: /\.openUserProfileModal.+?\)}\)}\)(?<=,(\i)&&(\i)&&(\(0,\i\.jsxs?\)\(\i\.\i,{className:(\i)\.divider}\)).+?)/,
|
|
||||||
replace: (m, hasMutualGuilds, hasMutualFriends, Divider, classes) => "" +
|
|
||||||
`${m},$self.renderDMPageList({user:arguments[0].user,hasDivider:${hasMutualGuilds}||${hasMutualFriends},Divider:${Divider},listStyle:${classes}.list})`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
getMutualGroupDms(userId: string) {
|
|
||||||
try {
|
|
||||||
return getMutualGroupDms(userId);
|
|
||||||
} catch (e) {
|
|
||||||
new Logger("MutualGroupDMs").error("Failed to get mutual group dms:", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
},
|
|
||||||
|
|
||||||
pushSection(sections: any[], user: User) {
|
pushSection(sections: any[], user: User) {
|
||||||
try {
|
if (isBotOrSelf(user) || sections[IS_PATCHED]) return;
|
||||||
if (isBotOrSelf(user) || sections[IS_PATCHED]) return;
|
|
||||||
|
|
||||||
sections[IS_PATCHED] = true;
|
sections[IS_PATCHED] = true;
|
||||||
sections.push({
|
sections.push({
|
||||||
section: "MUTUAL_GDMS",
|
section: "MUTUAL_GDMS",
|
||||||
text: getMutualGDMCountText(user)
|
text: getMutualGDMCountText(user)
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
new Logger("MutualGroupDMs").error("Failed to push mutual group dms section:", e);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
||||||
const mutualGDms = useMemo(() => getMutualGroupDms(user.id), [user.id]);
|
const mutualGDms = useMemo(() => getMutualGroupDms(user.id), [user.id]);
|
||||||
|
|
||||||
const entries = renderClickableGDMs(mutualGDms, onClose);
|
const entries = renderClickableGDMs(mutualGDms, onClose);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -159,13 +138,14 @@ export default definePlugin({
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
renderDMPageList: ErrorBoundary.wrap(({ user, hasDivider, Divider, listStyle }: { user: User, hasDivider: boolean, Divider: JSX.Element, listStyle: string; }) => {
|
renderDMPageList: ErrorBoundary.wrap(({ user, Divider, listStyle }: { user: User, Divider: JSX.Element, listStyle: string; }) => {
|
||||||
const mutualGDms = getMutualGroupDms(user.id);
|
const mutualGDms = getMutualGroupDms(user.id);
|
||||||
if (mutualGDms.length === 0) return null;
|
if (mutualGDms.length === 0) return null;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{hasDivider && Divider}
|
{Divider}
|
||||||
<ExpandableList
|
<ExpandableList
|
||||||
listClassName={listStyle}
|
listClassName={listStyle}
|
||||||
header={"Mutual Groups"}
|
header={"Mutual Groups"}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import {
|
||||||
findGroupChildrenByChildId,
|
findGroupChildrenByChildId,
|
||||||
NavContextMenuPatchCallback
|
NavContextMenuPatchCallback
|
||||||
} from "@api/ContextMenu";
|
} from "@api/ContextMenu";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||||
import { CogWheel } from "@components/Icons";
|
import { CogWheel } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
@ -115,6 +115,8 @@ function applyDefaultSettings(guildId: string | null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
migratePluginSettings("NewGuildSettings", "MuteNewGuild");
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NewGuildSettings",
|
name: "NewGuildSettings",
|
||||||
description: "Automatically mute new servers and change various other settings upon joining",
|
description: "Automatically mute new servers and change various other settings upon joining",
|
||||||
|
|
|
@ -16,27 +16,20 @@
|
||||||
* 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 { getUserSettingLazy } from "@api/UserSettings";
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
const DisableStreamPreviews = getUserSettingLazy<boolean>("voiceAndVideo", "disableStreamPreviews")!;
|
|
||||||
|
|
||||||
// @TODO: Delete this plugin in the future
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "NoScreensharePreview",
|
name: "NoScreensharePreview",
|
||||||
description: "Disables screenshare previews from being sent.",
|
description: "Disables screenshare previews from being sent.",
|
||||||
authors: [Devs.Nuckyz],
|
authors: [Devs.Nuckyz],
|
||||||
|
patches: [
|
||||||
start() {
|
{
|
||||||
if (!DisableStreamPreviews.getSetting()) {
|
find: '"ApplicationStreamPreviewUploadManager"',
|
||||||
DisableStreamPreviews.updateSetting(true);
|
replacement: {
|
||||||
|
match: /await \i\.\i\.(makeChunkedRequest\(|post\(\{url:)\i\.\i\.STREAM_PREVIEW.+?\}\)/g,
|
||||||
|
replace: "0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
]
|
||||||
|
|
||||||
stop() {
|
|
||||||
if (DisableStreamPreviews.getSetting()) {
|
|
||||||
DisableStreamPreviews.updateSetting(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +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 { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
|
import definePlugin, { OptionType, ReporterTestable } from "@utils/types";
|
||||||
import { FluxDispatcher } from "@webpack/common";
|
import { FluxDispatcher } from "@webpack/common";
|
||||||
|
@ -41,6 +41,7 @@ const settings = definePluginSettings({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migratePluginSettings("PartyMode", "Party mode 🎉");
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "PartyMode",
|
name: "PartyMode",
|
||||||
description: "Allows you to use party mode cause the party never ends ✨",
|
description: "Allows you to use party mode cause the party never ends ✨",
|
||||||
|
|
|
@ -22,12 +22,12 @@ import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
|
||||||
import { getIntlMessage, getUniqueUsername } from "@utils/discord";
|
import { getIntlMessage, 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 { findByCodeLazy } from "@webpack";
|
import { findByCodeLazy } from "@webpack";
|
||||||
import { Clipboard, ContextMenuApi, FluxDispatcher, GuildMemberStore, GuildStore, i18n, Menu, PermissionsBits, ScrollerThin, Text, Tooltip, useEffect, useMemo, UserStore, useState, useStateFromStores } from "@webpack/common";
|
import { Clipboard, ContextMenuApi, FluxDispatcher, GuildMemberStore, GuildStore, Menu, PermissionsBits, ScrollerThin, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||||
import { UnicodeEmoji } from "@webpack/types";
|
import { UnicodeEmoji } from "@webpack/types";
|
||||||
import type { Guild, Role, User } from "discord-types/general";
|
import type { Guild, Role, User } from "discord-types/general";
|
||||||
|
|
||||||
import { settings } from "..";
|
import { settings } from "..";
|
||||||
import { cl, getGuildPermissionSpecMap } from "../utils";
|
import { cl, getPermissionDescription, getPermissionString } from "../utils";
|
||||||
import { PermissionAllowedIcon, PermissionDefaultIcon, PermissionDeniedIcon } from "./icons";
|
import { PermissionAllowedIcon, PermissionDefaultIcon, PermissionDeniedIcon } from "./icons";
|
||||||
|
|
||||||
export const enum PermissionType {
|
export const enum PermissionType {
|
||||||
|
@ -56,7 +56,7 @@ function getRoleIconSrc(role: Role) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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; }) {
|
||||||
const guildPermissionSpecMap = useMemo(() => getGuildPermissionSpecMap(guild), [guild.id]);
|
permissions.sort((a, b) => a.type - b.type);
|
||||||
|
|
||||||
useStateFromStores(
|
useStateFromStores(
|
||||||
[GuildMemberStore],
|
[GuildMemberStore],
|
||||||
|
@ -65,10 +65,6 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
(old, current) => old.length === current.length
|
(old, current) => old.length === current.length
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
permissions.sort((a, b) => a.type - b.type);
|
|
||||||
}, [permissions]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const usersToRequest = permissions
|
const usersToRequest = permissions
|
||||||
.filter(p => p.type === PermissionType.User && !GuildMemberStore.isMember(guild.id, p.id!))
|
.filter(p => p.type === PermissionType.User && !GuildMemberStore.isMember(guild.id, p.id!))
|
||||||
|
@ -177,7 +173,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
</ScrollerThin>
|
</ScrollerThin>
|
||||||
<div className={cl("modal-divider")} />
|
<div className={cl("modal-divider")} />
|
||||||
<ScrollerThin className={cl("modal-perms")} orientation="auto">
|
<ScrollerThin className={cl("modal-perms")} orientation="auto">
|
||||||
{Object.values(PermissionsBits).map(bit => (
|
{Object.entries(PermissionsBits).map(([permissionName, bit]) => (
|
||||||
<div className={cl("modal-perms-item")}>
|
<div className={cl("modal-perms-item")}>
|
||||||
<div className={cl("modal-perms-item-icon")}>
|
<div className={cl("modal-perms-item-icon")}>
|
||||||
{(() => {
|
{(() => {
|
||||||
|
@ -196,14 +192,9 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||||
return PermissionDefaultIcon();
|
return PermissionDefaultIcon();
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
<Text variant="text-md/normal">{guildPermissionSpecMap[String(bit)].title}</Text>
|
<Text variant="text-md/normal">{getPermissionString(permissionName)}</Text>
|
||||||
|
|
||||||
<Tooltip text={
|
<Tooltip text={getPermissionDescription(permissionName) || "No Description"}>
|
||||||
(() => {
|
|
||||||
const { description } = guildPermissionSpecMap[String(bit)];
|
|
||||||
return typeof description === "function" ? i18n.intl.format(description, {}) : description;
|
|
||||||
})()
|
|
||||||
}>
|
|
||||||
{props => <InfoIcon {...props} />}
|
{props => <InfoIcon {...props} />}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { ExpandableHeader } from "@components/ExpandableHeader";
|
||||||
import { getIntlMessage } from "@utils/discord";
|
import { getIntlMessage } from "@utils/discord";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
import { filters, findBulk, proxyLazyWebpack } from "@webpack";
|
||||||
|
@ -24,7 +25,7 @@ import { PermissionsBits, Text, Tooltip, useMemo, UserStore } from "@webpack/com
|
||||||
import type { Guild, GuildMember } from "discord-types/general";
|
import type { Guild, GuildMember } from "discord-types/general";
|
||||||
|
|
||||||
import { PermissionsSortOrder, settings } from "..";
|
import { PermissionsSortOrder, settings } from "..";
|
||||||
import { cl, getGuildPermissionSpecMap, getSortedRoles, sortUserRoles } from "../utils";
|
import { cl, getPermissionString, getSortedRoles, sortUserRoles } from "../utils";
|
||||||
import openRolesAndUsersPermissionsModal, { PermissionType, type RoleOrUserPermission } from "./RolesAndUsersPermissions";
|
import openRolesAndUsersPermissionsModal, { PermissionType, type RoleOrUserPermission } from "./RolesAndUsersPermissions";
|
||||||
|
|
||||||
interface UserPermission {
|
interface UserPermission {
|
||||||
|
@ -86,11 +87,9 @@ function GrantedByTooltip({ roleName, roleColor }: GrantedByTooltipProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild: Guild; guildMember: GuildMember; closePopout: () => void; }) {
|
function UserPermissionsComponent({ guild, guildMember, forceOpen = false }: { guild: Guild; guildMember: GuildMember; forceOpen?: boolean; }) {
|
||||||
const { permissionsSortOrder } = settings.use(["permissionsSortOrder"]);
|
const { permissionsSortOrder } = settings.use(["permissionsSortOrder"]);
|
||||||
|
|
||||||
const guildPermissionSpecMap = useMemo(() => getGuildPermissionSpecMap(guild), [guild.id]);
|
|
||||||
|
|
||||||
const [rolePermissions, userPermissions] = useMemo(() => {
|
const [rolePermissions, userPermissions] = useMemo(() => {
|
||||||
const userPermissions: UserPermissions = [];
|
const userPermissions: UserPermissions = [];
|
||||||
|
|
||||||
|
@ -107,7 +106,7 @@ function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild:
|
||||||
permissions: Object.values(PermissionsBits).reduce((prev, curr) => prev | curr, 0n)
|
permissions: Object.values(PermissionsBits).reduce((prev, curr) => prev | curr, 0n)
|
||||||
});
|
});
|
||||||
|
|
||||||
const OWNER = getIntlMessage("GUILD_OWNER") ?? "Server Owner";
|
const OWNER = getIntlMessage("GUILD_OWNER") || "Server Owner";
|
||||||
userPermissions.push({
|
userPermissions.push({
|
||||||
permission: OWNER,
|
permission: OWNER,
|
||||||
roleName: "Owner",
|
roleName: "Owner",
|
||||||
|
@ -118,11 +117,11 @@ function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild:
|
||||||
|
|
||||||
sortUserRoles(userRoles);
|
sortUserRoles(userRoles);
|
||||||
|
|
||||||
for (const bit of Object.values(PermissionsBits)) {
|
for (const [permission, bit] of Object.entries(PermissionsBits)) {
|
||||||
for (const { permissions, colorString, position, name } of userRoles) {
|
for (const { permissions, colorString, position, name } of userRoles) {
|
||||||
if ((permissions & bit) === bit) {
|
if ((permissions & bit) === bit) {
|
||||||
userPermissions.push({
|
userPermissions.push({
|
||||||
permission: guildPermissionSpecMap[String(bit)].title,
|
permission: getPermissionString(permission),
|
||||||
roleName: name,
|
roleName: name,
|
||||||
roleColor: colorString || "var(--primary-300)",
|
roleColor: colorString || "var(--primary-300)",
|
||||||
rolePosition: position
|
rolePosition: position
|
||||||
|
@ -138,15 +137,26 @@ function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild:
|
||||||
return [rolePermissions, userPermissions];
|
return [rolePermissions, userPermissions];
|
||||||
}, [permissionsSortOrder]);
|
}, [permissionsSortOrder]);
|
||||||
|
|
||||||
return <div>
|
return (
|
||||||
<div className={cl("user-header-container")}>
|
<ExpandableHeader
|
||||||
<Text variant="eyebrow">Permissions</Text>
|
forceOpen={forceOpen}
|
||||||
<div className={cl("user-header-btns")}>
|
headerText="Permissions"
|
||||||
|
moreTooltipText="Role Details"
|
||||||
|
onMoreClick={() =>
|
||||||
|
openRolesAndUsersPermissionsModal(
|
||||||
|
rolePermissions,
|
||||||
|
guild,
|
||||||
|
guildMember.nick || UserStore.getUser(guildMember.userId).username
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onDropDownClick={state => settings.store.defaultPermissionsDropdownState = !state}
|
||||||
|
defaultState={settings.store.defaultPermissionsDropdownState}
|
||||||
|
buttons={[
|
||||||
<Tooltip text={`Sorting by ${permissionsSortOrder === PermissionsSortOrder.HighestRole ? "Highest Role" : "Lowest Role"}`}>
|
<Tooltip text={`Sorting by ${permissionsSortOrder === PermissionsSortOrder.HighestRole ? "Highest Role" : "Lowest Role"}`}>
|
||||||
{tooltipProps => (
|
{tooltipProps => (
|
||||||
<div
|
<div
|
||||||
{...tooltipProps}
|
{...tooltipProps}
|
||||||
className={cl("user-header-btn")}
|
className={cl("user-sortorder-btn")}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -154,8 +164,8 @@ function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild:
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
width="24"
|
width="20"
|
||||||
height="24"
|
height="20"
|
||||||
viewBox="0 96 960 960"
|
viewBox="0 96 960 960"
|
||||||
transform={permissionsSortOrder === PermissionsSortOrder.HighestRole ? "scale(1 1)" : "scale(1 -1)"}
|
transform={permissionsSortOrder === PermissionsSortOrder.HighestRole ? "scale(1 1)" : "scale(1 -1)"}
|
||||||
>
|
>
|
||||||
|
@ -164,46 +174,24 @@ function UserPermissionsComponent({ guild, guildMember, closePopout }: { guild:
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip text="Role Details">
|
]}>
|
||||||
{tooltipProps => (
|
{userPermissions.length > 0 && (
|
||||||
<div
|
<div className={classes(RoleRootClasses.root)}>
|
||||||
{...tooltipProps}
|
{userPermissions.map(({ permission, roleColor, roleName }) => (
|
||||||
className={cl("user-header-btn")}
|
<Tooltip
|
||||||
role="button"
|
text={<GrantedByTooltip roleName={roleName} roleColor={roleColor} />}
|
||||||
tabIndex={0}
|
tooltipClassName={cl("granted-by-container")}
|
||||||
onClick={() => {
|
tooltipContentClassName={cl("granted-by-content")}
|
||||||
closePopout();
|
|
||||||
openRolesAndUsersPermissionsModal(rolePermissions, guild, guildMember.nick || UserStore.getUser(guildMember.userId).username);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<svg
|
{tooltipProps => (
|
||||||
width="24"
|
<FakeRole {...tooltipProps} text={permission} color={roleColor} />
|
||||||
height="24"
|
)}
|
||||||
viewBox="0 0 24 24"
|
</Tooltip>
|
||||||
>
|
))}
|
||||||
<path fill="var(--text-normal)" d="M7 12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 10.8964 17.8954 10.001 19 10.001Z" />
|
</div>
|
||||||
</svg>
|
)}
|
||||||
</div>
|
</ExpandableHeader>
|
||||||
)}
|
);
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{userPermissions.length > 0 && (
|
|
||||||
<div className={classes(RoleRootClasses.root)}>
|
|
||||||
{userPermissions.map(({ permission, roleColor, roleName }) => (
|
|
||||||
<Tooltip
|
|
||||||
text={<GrantedByTooltip roleName={roleName} roleColor={roleColor} />}
|
|
||||||
tooltipClassName={cl("granted-by-container")}
|
|
||||||
tooltipContentClassName={cl("granted-by-content")}
|
|
||||||
>
|
|
||||||
{tooltipProps => (
|
|
||||||
<FakeRole {...tooltipProps} text={permission} color={roleColor} />
|
|
||||||
)}
|
|
||||||
</Tooltip>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ErrorBoundary.wrap(UserPermissionsComponent, { noop: true });
|
export default ErrorBoundary.wrap(UserPermissionsComponent, { noop: true });
|
||||||
|
|
|
@ -56,6 +56,11 @@ export const settings = definePluginSettings({
|
||||||
{ label: "Lowest Role", value: PermissionsSortOrder.LowestRole }
|
{ label: "Lowest Role", value: PermissionsSortOrder.LowestRole }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
defaultPermissionsDropdownState: {
|
||||||
|
description: "Whether the permissions dropdown on user popouts should be open by default",
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) {
|
||||||
|
@ -177,9 +182,9 @@ export default definePlugin({
|
||||||
<Popout
|
<Popout
|
||||||
position="bottom"
|
position="bottom"
|
||||||
align="center"
|
align="center"
|
||||||
renderPopout={({ closePopout }) => (
|
renderPopout={() => (
|
||||||
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
<Dialog className={PopoutClasses.container} style={{ width: "500px" }}>
|
||||||
<UserPermissions guild={guild} guildMember={guildMember} closePopout={closePopout} />
|
<UserPermissions guild={guild} guildMember={guildMember} forceOpen />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,22 +1,12 @@
|
||||||
/* User Permissions Component */
|
/* User Permissions Component */
|
||||||
|
|
||||||
.vc-permviewer-user-header-container {
|
.vc-permviewer-user-sortorder-btn {
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-permviewer-user-header-btns {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-permviewer-user-header-btn {
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RolesAndUsersPermissions Component */
|
/* RolesAndUsersPermissions Component */
|
||||||
|
|
|
@ -17,17 +17,57 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { getIntlMessage } from "@utils/discord";
|
||||||
import { GuildStore } from "@webpack/common";
|
import { wordsToTitle } from "@utils/text";
|
||||||
|
import { GuildStore, Parser } from "@webpack/common";
|
||||||
import { Guild, GuildMember, Role } from "discord-types/general";
|
import { Guild, GuildMember, Role } from "discord-types/general";
|
||||||
|
import type { ReactNode } from "react";
|
||||||
|
|
||||||
import { PermissionsSortOrder, settings } from ".";
|
import { PermissionsSortOrder, settings } from ".";
|
||||||
import { PermissionType } from "./components/RolesAndUsersPermissions";
|
import { PermissionType } from "./components/RolesAndUsersPermissions";
|
||||||
|
|
||||||
export const { getGuildPermissionSpecMap } = findByPropsLazy("getGuildPermissionSpecMap");
|
|
||||||
|
|
||||||
export const cl = classNameFactory("vc-permviewer-");
|
export const cl = classNameFactory("vc-permviewer-");
|
||||||
|
|
||||||
|
function formatPermissionWithoutMatchingString(permission: string) {
|
||||||
|
return wordsToTitle(permission.toLowerCase().split("_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// because discord is unable to be consistent with their names
|
||||||
|
const PermissionKeyMap = {
|
||||||
|
MANAGE_GUILD: "MANAGE_SERVER",
|
||||||
|
MANAGE_GUILD_EXPRESSIONS: "MANAGE_EXPRESSIONS",
|
||||||
|
CREATE_GUILD_EXPRESSIONS: "CREATE_EXPRESSIONS",
|
||||||
|
MODERATE_MEMBERS: "MODERATE_MEMBER", // HELLOOOO ??????
|
||||||
|
STREAM: "VIDEO",
|
||||||
|
SEND_VOICE_MESSAGES: "ROLE_PERMISSIONS_SEND_VOICE_MESSAGE",
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export function getPermissionString(permission: string) {
|
||||||
|
permission = PermissionKeyMap[permission] || permission;
|
||||||
|
|
||||||
|
return getIntlMessage(permission) ||
|
||||||
|
// shouldn't get here but just in case
|
||||||
|
formatPermissionWithoutMatchingString(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPermissionDescription(permission: string): ReactNode {
|
||||||
|
// DISCORD PLEEEEEEEEAAAAASE IM BEGGING YOU :(
|
||||||
|
if (permission === "USE_APPLICATION_COMMANDS")
|
||||||
|
permission = "USE_APPLICATION_COMMANDS_GUILD";
|
||||||
|
else if (permission === "SEND_VOICE_MESSAGES")
|
||||||
|
permission = "SEND_VOICE_MESSAGE_GUILD";
|
||||||
|
else if (permission !== "STREAM")
|
||||||
|
permission = PermissionKeyMap[permission] || permission;
|
||||||
|
|
||||||
|
const msg = getIntlMessage(`ROLE_PERMISSIONS_${permission}_DESCRIPTION`) as any;
|
||||||
|
if (msg?.hasMarkdown)
|
||||||
|
return Parser.parse(msg.message);
|
||||||
|
|
||||||
|
if (typeof msg === "string") return msg;
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
export function getSortedRoles({ id }: Guild, member: GuildMember) {
|
export function getSortedRoles({ id }: Guild, member: GuildMember) {
|
||||||
const roles = GuildStore.getRoles(id);
|
const roles = GuildStore.getRoles(id);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
|
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";
|
||||||
import { Menu } from "@webpack/common";
|
import { Menu } from "@webpack/common";
|
||||||
|
@ -24,6 +25,7 @@ const Patch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild;
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
migratePluginSettings("ServerInfo", "ServerProfile"); // what was I thinking with this name lmao
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ServerInfo",
|
name: "ServerInfo",
|
||||||
description: "Allows you to view info about a server",
|
description: "Allows you to view info about a server",
|
||||||
|
|
|
@ -20,9 +20,9 @@ import { addServerListElement, removeServerListElement, ServerListRenderPosition
|
||||||
import { Settings } from "@api/Settings";
|
import { Settings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { useForceUpdater } from "@utils/react";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findStoreLazy } from "@webpack";
|
import { GuildStore, PresenceStore, RelationshipStore } from "@webpack/common";
|
||||||
import { GuildStore, PresenceStore, RelationshipStore, useStateFromStores } from "@webpack/common";
|
|
||||||
|
|
||||||
const enum IndicatorType {
|
const enum IndicatorType {
|
||||||
SERVER = 1 << 0,
|
SERVER = 1 << 0,
|
||||||
|
@ -30,24 +30,13 @@ const enum IndicatorType {
|
||||||
BOTH = SERVER | FRIEND,
|
BOTH = SERVER | FRIEND,
|
||||||
}
|
}
|
||||||
|
|
||||||
const UserGuildJoinRequestStore = findStoreLazy("UserGuildJoinRequestStore");
|
let onlineFriends = 0;
|
||||||
|
let guildCount = 0;
|
||||||
|
let forceUpdateFriendCount: () => void;
|
||||||
|
let forceUpdateGuildCount: () => void;
|
||||||
|
|
||||||
function FriendsIndicator() {
|
function FriendsIndicator() {
|
||||||
const onlineFriendsCount = useStateFromStores([RelationshipStore, PresenceStore], () => {
|
forceUpdateFriendCount = useForceUpdater();
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
const friendIds = RelationshipStore.getFriendIDs();
|
|
||||||
for (const id of friendIds) {
|
|
||||||
const status = PresenceStore.getStatus(id) ?? "offline";
|
|
||||||
if (status === "offline") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span id="vc-friendcount" style={{
|
<span id="vc-friendcount" style={{
|
||||||
|
@ -59,19 +48,13 @@ function FriendsIndicator() {
|
||||||
textTransform: "uppercase",
|
textTransform: "uppercase",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}>
|
}}>
|
||||||
{onlineFriendsCount} online
|
{onlineFriends} online
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ServersIndicator() {
|
function ServersIndicator() {
|
||||||
const guildCount = useStateFromStores([GuildStore, UserGuildJoinRequestStore], () => {
|
forceUpdateGuildCount = useForceUpdater();
|
||||||
const guildJoinRequests: string[] = UserGuildJoinRequestStore.computeGuildIds();
|
|
||||||
const guilds = GuildStore.getGuilds();
|
|
||||||
|
|
||||||
// Filter only pending guild join requests
|
|
||||||
return GuildStore.getGuildCount() + guildJoinRequests.filter(id => guilds[id] == null).length;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span id="vc-guildcount" style={{
|
<span id="vc-guildcount" style={{
|
||||||
|
@ -88,6 +71,24 @@ function ServersIndicator() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handlePresenceUpdate() {
|
||||||
|
onlineFriends = 0;
|
||||||
|
const relations = RelationshipStore.getRelationships();
|
||||||
|
for (const id of Object.keys(relations)) {
|
||||||
|
const type = relations[id];
|
||||||
|
// FRIEND relationship type
|
||||||
|
if (type === 1 && PresenceStore.getStatus(id) !== "offline") {
|
||||||
|
onlineFriends += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
forceUpdateFriendCount?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGuildUpdate() {
|
||||||
|
guildCount = GuildStore.getGuildCount();
|
||||||
|
forceUpdateGuildCount?.();
|
||||||
|
}
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ServerListIndicators",
|
name: "ServerListIndicators",
|
||||||
description: "Add online friend count or server count in the server list",
|
description: "Add online friend count or server count in the server list",
|
||||||
|
@ -116,8 +117,18 @@ export default definePlugin({
|
||||||
</ErrorBoundary>;
|
</ErrorBoundary>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
flux: {
|
||||||
|
PRESENCE_UPDATES: handlePresenceUpdate,
|
||||||
|
GUILD_CREATE: handleGuildUpdate,
|
||||||
|
GUILD_DELETE: handleGuildUpdate,
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
addServerListElement(ServerListRenderPosition.Above, this.renderIndicator);
|
addServerListElement(ServerListRenderPosition.Above, this.renderIndicator);
|
||||||
|
|
||||||
|
handlePresenceUpdate();
|
||||||
|
handleGuildUpdate();
|
||||||
},
|
},
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
|
|
@ -168,7 +168,7 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
// Add the hidden eye icon if the channel is hidden
|
// Add the hidden eye icon if the channel is hidden
|
||||||
{
|
{
|
||||||
match: /\.name,{.{0,140}\.children.+?:null(?<=,channel:(\i).+?)/,
|
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
||||||
replace: (m, channel) => `${m},$self.isHiddenChannel(${channel})?$self.HiddenChannelIcon():null`
|
replace: (m, channel) => `${m},$self.isHiddenChannel(${channel})?$self.HiddenChannelIcon():null`
|
||||||
},
|
},
|
||||||
// Make voice channels also appear as muted if they are muted
|
// Make voice channels also appear as muted if they are muted
|
||||||
|
|
|
@ -16,7 +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 { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType, PluginSettingDef } from "@utils/types";
|
import definePlugin, { OptionType, PluginSettingDef } from "@utils/types";
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ const settings = definePluginSettings({
|
||||||
disableDisallowedDiscoveryFilters: opt("Disable filters in Server Discovery search that hide NSFW & disallowed servers."),
|
disableDisallowedDiscoveryFilters: opt("Disable filters in Server Discovery search that hide NSFW & disallowed servers."),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migratePluginSettings("ShowHiddenThings", "ShowTimeouts");
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "ShowHiddenThings",
|
name: "ShowHiddenThings",
|
||||||
tags: ["ShowTimeouts", "ShowInvitesPaused", "ShowModView", "DisableDiscoveryFilters"],
|
tags: ["ShowTimeouts", "ShowInvitesPaused", "ShowModView", "DisableDiscoveryFilters"],
|
||||||
|
@ -74,15 +75,6 @@ export default definePlugin({
|
||||||
replace: "$1$2arguments[0].member.highestRoleId]",
|
replace: "$1$2arguments[0].member.highestRoleId]",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// allows you to open mod view on yourself
|
|
||||||
{
|
|
||||||
find: ".MEMBER_SAFETY,{modViewPanel:",
|
|
||||||
predicate: () => settings.store.showModView,
|
|
||||||
replacement: {
|
|
||||||
match: /\i(?=\?null)/,
|
|
||||||
replace: "false"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: "prod_discoverable_guilds",
|
find: "prod_discoverable_guilds",
|
||||||
predicate: () => settings.store.disableDiscoveryFilters,
|
predicate: () => settings.store.disableDiscoveryFilters,
|
||||||
|
|
|
@ -54,17 +54,9 @@ const SilentTypingToggle: ChatBarButton = ({ isMainChat }) => {
|
||||||
tooltip={isEnabled ? "Disable Silent Typing" : "Enable Silent Typing"}
|
tooltip={isEnabled ? "Disable Silent Typing" : "Enable Silent Typing"}
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
>
|
>
|
||||||
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style={{ scale: "1.2" }}>
|
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
|
||||||
<path fill="currentColor" mask="url(#silent-typing-msg-mask)" d="M18.333 15.556H1.667a1.667 1.667 0 0 1 -1.667 -1.667v-10a1.667 1.667 0 0 1 1.667 -1.667h16.667a1.667 1.667 0 0 1 1.667 1.667v10a1.667 1.667 0 0 1 -1.667 1.667M4.444 6.25V4.861a0.417 0.417 0 0 0 -0.417 -0.417H2.639a0.417 0.417 0 0 0 -0.417 0.417V6.25a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V4.861a0.417 0.417 0 0 0 -0.417 -0.417H5.973a0.417 0.417 0 0 0 -0.417 0.417V6.25a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V4.861a0.417 0.417 0 0 0 -0.417 -0.417h-1.389a0.417 0.417 0 0 0 -0.417 0.417V6.25a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V4.861a0.417 0.417 0 0 0 -0.417 -0.417h-1.389a0.417 0.417 0 0 0 -0.417 0.417V6.25a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V4.861a0.417 0.417 0 0 0 -0.417 -0.417h-1.389a0.417 0.417 0 0 0 -0.417 0.417V6.25a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m-11.667 3.333V8.194a0.417 0.417 0 0 0 -0.417 -0.417H4.306a0.417 0.417 0 0 0 -0.417 0.417V9.583a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V8.194a0.417 0.417 0 0 0 -0.417 -0.417H7.639a0.417 0.417 0 0 0 -0.417 0.417V9.583a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V8.194a0.417 0.417 0 0 0 -0.417 -0.417h-1.389a0.417 0.417 0 0 0 -0.417 0.417V9.583a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m3.333 0V8.194a0.417 0.417 0 0 0 -0.417 -0.417h-1.389a0.417 0.417 0 0 0 -0.417 0.417V9.583a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m-11.667 3.333v-1.389a0.417 0.417 0 0 0 -0.417 -0.417H2.639a0.417 0.417 0 0 0 -0.417 0.417V12.917a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417m10 0v-1.389a0.417 0.417 0 0 0 -0.417 -0.417H5.973a0.417 0.417 0 0 0 -0.417 0.417V12.917a0.417 0.417 0 0 0 0.417 0.417h8.056a0.417 0.417 0 0 0 0.417 -0.417m3.333 0v-1.389a0.417 0.417 0 0 0 -0.417 -0.417h-1.389a0.417 0.417 0 0 0 -0.417 0.417V12.917a0.417 0.417 0 0 0 0.417 0.417h1.389a0.417 0.417 0 0 0 0.417 -0.417" transform="translate(2, 3)" />
|
<path fill="currentColor" d="M528 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h480c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM128 180v-40c0-6.627-5.373-12-12-12H76c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm-336 96v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm-336 96v-40c0-6.627-5.373-12-12-12H76c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12zm288 0v-40c0-6.627-5.373-12-12-12H172c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h232c6.627 0 12-5.373 12-12zm96 0v-40c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12z" />
|
||||||
{isEnabled && (
|
{isEnabled && <path d="M13 432L590 48" stroke="var(--red-500)" stroke-width="72" stroke-linecap="round" />}
|
||||||
<>
|
|
||||||
<mask id="silent-typing-msg-mask">
|
|
||||||
<path fill="#fff" d="M0 0h24v24H0Z"></path>
|
|
||||||
<path stroke="#000" strokeWidth="5.99068" d="M0 24 24 0" transform="translate(-2, -3)"></path>
|
|
||||||
</mask>
|
|
||||||
<path fill="var(--status-danger)" d="m21.178 1.70703 1.414 1.414L4.12103 21.593l-1.414-1.415L21.178 1.70703Z" />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</svg>
|
</svg>
|
||||||
</ChatBarButton>
|
</ChatBarButton>
|
||||||
);
|
);
|
||||||
|
|
|
@ -163,7 +163,7 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "UNREAD_IMPORTANT:",
|
find: "UNREAD_IMPORTANT:",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.name,{.{0,140}\.children.+?:null(?<=,channel:(\i).+?)/,
|
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
||||||
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
|
replace: "$&,$self.TypingIndicator($1.id,$1.getGuildId())"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -91,31 +91,34 @@ export default definePlugin({
|
||||||
name: "TypingTweaks",
|
name: "TypingTweaks",
|
||||||
description: "Show avatars and role colours in the typing indicator",
|
description: "Show avatars and role colours in the typing indicator",
|
||||||
authors: [Devs.zt],
|
authors: [Devs.zt],
|
||||||
settings,
|
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
|
// Style the indicator and add function call to modify the children before rendering
|
||||||
{
|
{
|
||||||
find: "#{intl::THREE_USERS_TYPING}",
|
find: "getCooldownTextStyle",
|
||||||
replacement: [
|
replacement: {
|
||||||
{
|
match: /(?<=children:\[(\i)\.length>0.{0,200}?"aria-atomic":!0,children:)\i/,
|
||||||
// Style the indicator and add function call to modify the children before rendering
|
replace: "$self.mutateChildren(this.props, $1, $&), style: $self.TYPING_TEXT_STYLE"
|
||||||
match: /(?<=children:\[(\i)\.length>0.{0,200}?"aria-atomic":!0,children:)\i(?<=guildId:(\i).+?)/,
|
}
|
||||||
replace: "$self.mutateChildren($2,$1,$&),style:$self.TYPING_TEXT_STYLE"
|
},
|
||||||
},
|
// Changes the indicator to keep the user object when creating the list of typing users
|
||||||
{
|
{
|
||||||
// Changes the indicator to keep the user object when creating the list of typing users
|
find: "getCooldownTextStyle",
|
||||||
match: /\.map\((\i)=>\i\.\i\.getName\(\i,\i\.id,\1\)\)/,
|
replacement: {
|
||||||
replace: ""
|
match: /(?<=map\(\i=>)\i\.\i\.getName\(\i,this\.props\.channel\.id,(\i)\)/,
|
||||||
},
|
replace: "$1"
|
||||||
{
|
}
|
||||||
// Adds the alternative formatting for several users typing
|
},
|
||||||
match: /(,{a:(\i),b:(\i),c:\i}\):\i\.length>3&&\(\i=)\i\.\i\.string\(\i\.\i#{intl::SEVERAL_USERS_TYPING}\)(?<=(\i)\.length.+?)/,
|
// Adds the alternative formatting for several users typing
|
||||||
replace: (_, rest, a, b, users) => `${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2 })`,
|
{
|
||||||
predicate: () => settings.store.alternativeFormatting
|
find: "getCooldownTextStyle",
|
||||||
}
|
replacement: {
|
||||||
]
|
match: /(,{a:(\i),b:(\i),c:\i}\):)\i\.\i\.string\(\i\.\i#{intl::SEVERAL_USERS_TYPING}\)(?<=(\i)\.length.+?)/,
|
||||||
|
replace: (_, rest, a, b, users) => `${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2 })`
|
||||||
|
},
|
||||||
|
predicate: () => settings.store.alternativeFormatting
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
settings,
|
||||||
|
|
||||||
TYPING_TEXT_STYLE: {
|
TYPING_TEXT_STYLE: {
|
||||||
display: "grid",
|
display: "grid",
|
||||||
|
@ -125,7 +128,7 @@ export default definePlugin({
|
||||||
|
|
||||||
buildSeveralUsers,
|
buildSeveralUsers,
|
||||||
|
|
||||||
mutateChildren(guildId: any, users: User[], children: any) {
|
mutateChildren(props: any, users: User[], children: any) {
|
||||||
try {
|
try {
|
||||||
if (!Array.isArray(children)) {
|
if (!Array.isArray(children)) {
|
||||||
return children;
|
return children;
|
||||||
|
@ -135,7 +138,7 @@ export default definePlugin({
|
||||||
|
|
||||||
return children.map(c =>
|
return children.map(c =>
|
||||||
c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c))
|
c.type === "strong" || (typeof c !== "string" && !React.isValidElement(c))
|
||||||
? <TypingUser guildId={guildId} user={users[element++]} />
|
? <TypingUser {...props} user={users[element++]} />
|
||||||
: c
|
: c
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -164,8 +164,8 @@ export default definePlugin({
|
||||||
find: 'getElementById("slate-toolbar"',
|
find: 'getElementById("slate-toolbar"',
|
||||||
predicate: () => settings.store.addBack,
|
predicate: () => settings.store.addBack,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /(?<=handleContextMenu\(\i\)\{.{0,200}isPlatformEmbedded)\)/,
|
match: /(?<=handleContextMenu\(\i\)\{.{0,200}isPlatformEmbedded)\?/,
|
||||||
replace: "||true)"
|
replace: "||true?"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -216,12 +216,9 @@ export default definePlugin({
|
||||||
replace: "true"
|
replace: "true"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: /\i\.\i\.copy(?=\(\i)/,
|
match: /\i\.\i\.copy/,
|
||||||
replace: "Vencord.Webpack.Common.Clipboard.copy"
|
replace: "Vencord.Webpack.Common.Clipboard.copy"
|
||||||
}
|
}]
|
||||||
],
|
|
||||||
all: true,
|
|
||||||
noWarn: true
|
|
||||||
},
|
},
|
||||||
// Automod add filter words
|
// Automod add filter words
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
// The entire code of this plugin can be found in native.ts
|
// The entire code of this plugin can be found in native.ts
|
||||||
|
migratePluginSettings("YoutubeAdblock", "WatchTogetherAdblock");
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "YoutubeAdblock",
|
name: "YoutubeAdblock",
|
||||||
description: "Block ads in YouTube embeds and the WatchTogether activity via AdGuard",
|
description: "Block ads in YouTube embeds and the WatchTogether activity via AdGuard",
|
||||||
|
|
|
@ -22,7 +22,6 @@ import { findByPropsLazy, waitFor } from "../webpack";
|
||||||
export let React: typeof import("react");
|
export let React: typeof import("react");
|
||||||
export let useState: typeof React.useState;
|
export let useState: typeof React.useState;
|
||||||
export let useEffect: typeof React.useEffect;
|
export let useEffect: typeof React.useEffect;
|
||||||
export let useLayoutEffect: typeof React.useLayoutEffect;
|
|
||||||
export let useMemo: typeof React.useMemo;
|
export let useMemo: typeof React.useMemo;
|
||||||
export let useRef: typeof React.useRef;
|
export let useRef: typeof React.useRef;
|
||||||
export let useReducer: typeof React.useReducer;
|
export let useReducer: typeof React.useReducer;
|
||||||
|
@ -32,5 +31,5 @@ export const ReactDOM: typeof import("react-dom") & typeof import("react-dom/cli
|
||||||
|
|
||||||
waitFor("useState", m => {
|
waitFor("useState", m => {
|
||||||
React = m;
|
React = m;
|
||||||
({ useEffect, useState, useLayoutEffect, useMemo, useRef, useReducer, useCallback } = React);
|
({ useEffect, useState, useMemo, useRef, useReducer, useCallback } = React);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue