Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bf34b2ae43 | ||
|
cb5f23d9b5 | ||
|
cd2cbfa0ef | ||
|
232e340fab | ||
|
8027daa2b0 | ||
|
0f7b9f588e | ||
|
93482ac2a5 | ||
|
994c3b3c92 | ||
|
c696c186e8 | ||
|
30d5e2108f | ||
|
1eabd1b701 | ||
|
1cbf2b43e1 | ||
|
4c197d5d51 | ||
|
f89027f46a | ||
|
07a0ebb1d2 | ||
|
f09b44b0d5 | ||
|
b607eebcb7 | ||
|
0936ca2985 | ||
|
13bde79ec8 | ||
|
b592defaaf | ||
|
73354973a3 | ||
|
e12c0e546c | ||
|
088a8bd1b6 | ||
|
51adb26d01 | ||
|
cb980a1cad | ||
|
69b10c1f07 | ||
|
8e9ba7c7ee | ||
|
12e3c9234d | ||
|
1d8dcef394 | ||
|
4fe2845234 | ||
|
5e71ed286e | ||
|
5edbd2391d | ||
|
8472c3823e | ||
|
2103e52115 | ||
|
afbfb641e8 | ||
|
d7ac418e05 | ||
|
214c101740 | ||
|
5a0e501829 | ||
|
92113da7c0 | ||
|
96f30a5359 | ||
|
ceb1f15188 | ||
|
626eb3613e | ||
|
3020fcc9bb | ||
|
bc0de3926c | ||
|
9820b79dfe | ||
|
ab811470fc | ||
|
e4162e7bd5 |
@ -39,10 +39,9 @@ Or use the [UserScript](https://raw.githubusercontent.com/Vencord/builds/main/Ve
|
||||
## Vencord Desktop
|
||||
|
||||
> **Warning**
|
||||
> This is an alternative app. It currently doesn't support screensharing or keybinds. If you just want to install to the normal Discord Desktop app, scroll up
|
||||
> This is an alternative app. It currently doesn't support keybinds and possibly some more features. If you just want to install to the normal Discord Desktop app, scroll up
|
||||
|
||||
|
||||
As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app. It is currently in beta and we have yet to implement some features like screensharing, but you can try the beta nonetheless
|
||||
As an alternative to the Discord Desktop app, Vencord also has its own standalone Desktop app that is snappier and lighter than Discord's official Desktop app
|
||||
|
||||
[![Download Vencord Desktop](https://img.shields.io/github/v/release/Vencord/Desktop?label=Download%20Vencord%20Desktop&style=for-the-badge)](https://github.com/Vencord/Desktop#vencord-desktop)
|
||||
|
||||
@ -50,7 +49,7 @@ As an alternative to the Discord Desktop app, Vencord also has its own standalon
|
||||
|
||||
## Join our Support/Community Server
|
||||
|
||||
[![Vencord Discord Server](https://invidget.switchblade.xyz/D9uwnFnqmd?theme=dark)](https://discord.gg/D9uwnFnqmd)
|
||||
https://discord.gg/D9uwnFnqmd
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vencord",
|
||||
"private": "true",
|
||||
"version": "1.2.8",
|
||||
"version": "1.3.3",
|
||||
"description": "The cutest Discord client mod",
|
||||
"homepage": "https://github.com/Vendicated/Vencord#readme",
|
||||
"bugs": {
|
||||
|
@ -151,7 +151,6 @@ async function parseFile(fileName: string) {
|
||||
case "required":
|
||||
case "enabledByDefault":
|
||||
data[key] = value.kind === SyntaxKind.TrueKeyword;
|
||||
if (!data[key] && value.kind !== SyntaxKind.FalseKeyword) throw fail(`${key} is not a boolean literal`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -58,4 +58,10 @@ export default {
|
||||
getVersions: () => process.versions as Partial<NodeJS.ProcessVersions>,
|
||||
openExternal: (url: string) => invoke<void>(IpcEvents.OPEN_EXTERNAL, url)
|
||||
},
|
||||
|
||||
pluginHelpers: {
|
||||
OpenInApp: {
|
||||
resolveRedirect: (url: string) => invoke<string>(IpcEvents.OPEN_IN_APP__RESOLVE_REDIRECT, url),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -254,8 +254,12 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
export function definePluginSettings<D extends SettingsDefinition, C extends SettingsChecks<D>>(def: D, checks?: C) {
|
||||
const definedSettings: DefinedSettings<D> = {
|
||||
export function definePluginSettings<
|
||||
Def extends SettingsDefinition,
|
||||
Checks extends SettingsChecks<Def>,
|
||||
PrivateSettings extends object = {}
|
||||
>(def: Def, checks?: Checks) {
|
||||
const definedSettings: DefinedSettings<Def, Checks, PrivateSettings> = {
|
||||
get store() {
|
||||
if (!definedSettings.pluginName) throw new Error("Cannot access settings before plugin is initialized");
|
||||
return Settings.plugins[definedSettings.pluginName] as any;
|
||||
@ -264,11 +268,11 @@ export function definePluginSettings<D extends SettingsDefinition, C extends Set
|
||||
settings?.map(name => `plugins.${definedSettings.pluginName}.${name}`) as UseSettings<Settings>[]
|
||||
).plugins[definedSettings.pluginName] as any,
|
||||
def,
|
||||
checks: checks ?? {},
|
||||
checks: checks ?? {} as any,
|
||||
pluginName: "",
|
||||
|
||||
withPrivateSettings<T>() {
|
||||
return this as DefinedSettings<D, C> & { store: T; };
|
||||
withPrivateSettings<T extends object>() {
|
||||
return this as DefinedSettings<Def, Checks, T>;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -86,7 +86,7 @@ function SettingsSyncSection() {
|
||||
<Button
|
||||
size={Button.Sizes.SMALL}
|
||||
disabled={!sectionEnabled}
|
||||
onClick={() => putCloudSettings()}
|
||||
onClick={() => putCloudSettings(true)}
|
||||
>Sync to Cloud</Button>
|
||||
<Tooltip text="This will overwrite your local settings with the ones on the cloud. Use wisely!">
|
||||
{({ onMouseLeave, onMouseEnter }) => (
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
import "./updater";
|
||||
import "./ipcPlugins";
|
||||
|
||||
import { debounce } from "@utils/debounce";
|
||||
import { IpcEvents } from "@utils/IpcEvents";
|
||||
|
46
src/main/ipcPlugins.ts
Normal file
46
src/main/ipcPlugins.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 { IpcEvents } from "@utils/IpcEvents";
|
||||
import { ipcMain } from "electron";
|
||||
import { request } from "https";
|
||||
|
||||
// #region OpenInApp
|
||||
// These links don't support CORS, so this has to be native
|
||||
const validRedirectUrls = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
||||
|
||||
function getRedirect(url: string) {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
const req = request(new URL(url), { method: "HEAD" }, res => {
|
||||
resolve(
|
||||
res.headers.location
|
||||
? getRedirect(res.headers.location)
|
||||
: url
|
||||
);
|
||||
});
|
||||
req.on("error", reject);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
ipcMain.handle(IpcEvents.OPEN_IN_APP__RESOLVE_REDIRECT, async (_, url: string) => {
|
||||
if (!validRedirectUrls.test(url)) return url;
|
||||
|
||||
return getRedirect(url);
|
||||
});
|
||||
// #endregion
|
@ -31,7 +31,8 @@ export const ALLOWED_PROTOCOLS = [
|
||||
"https:",
|
||||
"http:",
|
||||
"steam:",
|
||||
"spotify:"
|
||||
"spotify:",
|
||||
"com.epicgames.launcher:",
|
||||
];
|
||||
|
||||
export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
|
||||
|
@ -80,8 +80,8 @@ export default definePlugin({
|
||||
find: "Messages.PROFILE_USER_BADGES,role:",
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=(\i)\.isTryItOutFlow,)(.{0,300})null==\i\?void 0:(\i)\.getBadges\(\)/,
|
||||
replace: (_, props, restCode, badgesMod) => `vencordProps=${props},${restCode}Vencord.Api.Badges._getBadges(vencordProps).concat(${badgesMod}?.getBadges()??[])`,
|
||||
match: /&&(\i)\.push\(\{id:"premium".+?\}\);/,
|
||||
replace: "$&$1.unshift(...Vencord.Api.Badges._getBadges(arguments[0]));",
|
||||
},
|
||||
{
|
||||
// alt: "", aria-hidden: false, src: originalSrc
|
||||
|
@ -36,7 +36,8 @@ function Guilds(props: {
|
||||
// @ts-expect-error
|
||||
const res = Vencord.Plugins.plugins.BetterFolders.Guilds(props);
|
||||
|
||||
const scrollerProps = res.props.children?.props?.children?.[1]?.props;
|
||||
// TODO: Make this better
|
||||
const scrollerProps = res.props.children?.props?.children?.props?.children?.[1]?.props;
|
||||
if (scrollerProps?.children) {
|
||||
const servers = scrollerProps.children.find(c => c?.props?.["aria-label"] === i18n.Messages.SERVERS);
|
||||
if (servers) scrollerProps.children = servers;
|
||||
|
@ -45,7 +45,7 @@ function ToggleIconOff() {
|
||||
className={RegisteredGamesClasses.overlayToggleIconOff}
|
||||
height="24"
|
||||
width="24"
|
||||
viewBox="0 0 32 26"
|
||||
viewBox="0 2.2 32 26"
|
||||
aria-hidden={true}
|
||||
role="img"
|
||||
>
|
||||
@ -77,7 +77,7 @@ function ToggleIconOn({ forceWhite }: { forceWhite?: boolean; }) {
|
||||
className={RegisteredGamesClasses.overlayToggleIconOn}
|
||||
height="24"
|
||||
width="24"
|
||||
viewBox="0 0 32 26"
|
||||
viewBox="0 2.2 32 26"
|
||||
>
|
||||
<path
|
||||
className={forceWhite ? "" : RegisteredGamesClasses.fill}
|
||||
@ -119,7 +119,7 @@ function ToggleActivityComponentWithBackground({ activity }: { activity: Ignored
|
||||
return (
|
||||
<div
|
||||
className={`${TryItOutClasses.tryItOutBadge} ${BaseShapeRoundClasses.baseShapeRound}`}
|
||||
style={{ padding: "0px 2px" }}
|
||||
style={{ padding: "0px 2px", height: 28 }}
|
||||
>
|
||||
<ToggleActivityComponent activity={activity} forceWhite={true} />
|
||||
</div>
|
||||
@ -157,10 +157,16 @@ export default definePlugin({
|
||||
},
|
||||
{
|
||||
find: ".overlayBadge",
|
||||
replacement: {
|
||||
match: /(?<=\(\)\.badgeContainer.+?(\i)\.name}\):null)/,
|
||||
replace: (_, props) => `,$self.renderToggleActivityButton(${props})`
|
||||
}
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=\(\)\.badgeContainer,children:).{0,50}?name:(\i)\.name.+?null/,
|
||||
replace: (m, props) => `[${m},$self.renderToggleActivityButton(${props})]`
|
||||
},
|
||||
{
|
||||
match: /(?<=\(\)\.badgeContainer,children:).{0,50}?name:(\i\.application)\.name.+?null/,
|
||||
replace: (m, props) => `${m},$self.renderToggleActivityButton(${props})`
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
find: '.displayName="LocalActivityStore"',
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { classNameFactory } from "@api/Styles";
|
||||
import { FluxDispatcher, React, useRef, useState } from "@webpack/common";
|
||||
|
||||
import { ELEMENT_ID } from "../constants";
|
||||
@ -33,6 +34,8 @@ export interface MagnifierProps {
|
||||
instance: any;
|
||||
}
|
||||
|
||||
const cl = classNameFactory("vc-imgzoom-");
|
||||
|
||||
export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSize, zoom: initalZoom }) => {
|
||||
const [ready, setReady] = useState(false);
|
||||
|
||||
@ -156,7 +159,7 @@ export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSiz
|
||||
|
||||
return (
|
||||
<div
|
||||
className="vc-imgzoom-lens"
|
||||
className={cl("lens", { "nearest-neighbor": settings.store.nearestNeighbour, square: settings.store.square })}
|
||||
style={{
|
||||
opacity,
|
||||
width: size.current + "px",
|
||||
|
@ -23,7 +23,7 @@ import { makeRange } from "@components/PluginSettings/components";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { debounce } from "@utils/debounce";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Menu, React, ReactDOM } from "@webpack/common";
|
||||
import { ContextMenu, Menu, React, ReactDOM } from "@webpack/common";
|
||||
import type { Root } from "react-dom/client";
|
||||
|
||||
import { Magnifier, MagnifierProps } from "./components/Magnifier";
|
||||
@ -50,6 +50,18 @@ export const settings = definePluginSettings({
|
||||
default: true,
|
||||
},
|
||||
|
||||
nearestNeighbour: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Use Nearest Neighbour Interpolation when scaling images",
|
||||
default: false,
|
||||
},
|
||||
|
||||
square: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Make the lens square",
|
||||
default: false,
|
||||
},
|
||||
|
||||
zoom: {
|
||||
description: "Zoom of the lens",
|
||||
type: OptionType.SLIDER,
|
||||
@ -78,9 +90,17 @@ export const settings = definePluginSettings({
|
||||
const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
||||
children.push(
|
||||
<Menu.MenuGroup id="image-zoom">
|
||||
{/* thanks SpotifyControls */}
|
||||
<Menu.MenuCheckboxItem
|
||||
id="vc-square"
|
||||
label="Square Lens"
|
||||
checked={settings.store.square}
|
||||
action={() => {
|
||||
settings.store.square = !settings.store.square;
|
||||
ContextMenu.close();
|
||||
}}
|
||||
/>
|
||||
<Menu.MenuControlItem
|
||||
id="zoom"
|
||||
id="vc-zoom"
|
||||
label="Zoom"
|
||||
control={(props, ref) => (
|
||||
<Menu.MenuSliderControl
|
||||
@ -94,7 +114,7 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
||||
)}
|
||||
/>
|
||||
<Menu.MenuControlItem
|
||||
id="size"
|
||||
id="vc-size"
|
||||
label="Lens Size"
|
||||
control={(props, ref) => (
|
||||
<Menu.MenuSliderControl
|
||||
@ -108,7 +128,7 @@ const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
||||
)}
|
||||
/>
|
||||
<Menu.MenuControlItem
|
||||
id="zoom-speed"
|
||||
id="vc-zoom-speed"
|
||||
label="Zoom Speed"
|
||||
control={(props, ref) => (
|
||||
<Menu.MenuSliderControl
|
||||
|
@ -11,6 +11,14 @@
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.vc-imgzoom-square {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.vc-imgzoom-nearest-neighbor > img {
|
||||
image-rendering: pixelated; /* 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|="carouselModal"] {
|
||||
height: fit-content;
|
||||
|
@ -132,7 +132,7 @@ export default definePlugin({
|
||||
find: ".Messages.MESSAGE_EDITED,",
|
||||
replacement: {
|
||||
match: /var .,.,.=(.)\.className,.=.\.message,.=.\.children,.=.\.content,.=.\.onUpdate/gm,
|
||||
replace: "try {$1 && $self.INV_REGEX.test($1.content[0]) ? $1.content.push($self.indicator()) : null } catch {};$&"
|
||||
replace: "try {$1 && $self.INV_REGEX.test($1.message.content) ? $1.content.push($self.indicator()) : null } catch {};$&"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -200,8 +200,11 @@ export default definePlugin({
|
||||
},
|
||||
});
|
||||
|
||||
if (urlCheck?.length)
|
||||
message.embeds.push(await this.getEmbed(new URL(urlCheck[0])));
|
||||
if (urlCheck?.length) {
|
||||
const embed = await this.getEmbed(new URL(urlCheck[0]));
|
||||
if (embed)
|
||||
message.embeds.push(embed);
|
||||
}
|
||||
|
||||
this.updateMessage(message);
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ import { makeRange } from "@components/PluginSettings/components/SettingSliderCo
|
||||
import { Devs } from "@utils/constants";
|
||||
import { sleep } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { SelectedChannelStore, UserStore } from "@webpack/common";
|
||||
import { RelationshipStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
||||
import { Message, ReactionEmoji } from "discord-types/general";
|
||||
|
||||
interface IMessageCreate {
|
||||
@ -37,6 +37,7 @@ interface IReactionAdd {
|
||||
optimistic: boolean;
|
||||
channelId: string;
|
||||
messageId: string;
|
||||
messageAuthorId: string;
|
||||
userId: "195136840355807232";
|
||||
emoji: ReactionEmoji;
|
||||
}
|
||||
@ -71,6 +72,11 @@ const settings = definePluginSettings({
|
||||
description: "Ignore bots",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
},
|
||||
ignoreBlocked: {
|
||||
description: "Ignore blocked users",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true
|
||||
}
|
||||
});
|
||||
|
||||
@ -85,6 +91,7 @@ export default definePlugin({
|
||||
if (optimistic || type !== "MESSAGE_CREATE") return;
|
||||
if (message.state === "SENDING") return;
|
||||
if (settings.store.ignoreBots && message.author?.bot) return;
|
||||
if (settings.store.ignoreBlocked && RelationshipStore.isBlocked(message.author?.id)) return;
|
||||
if (!message.content) return;
|
||||
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||
|
||||
@ -96,9 +103,10 @@ export default definePlugin({
|
||||
}
|
||||
},
|
||||
|
||||
MESSAGE_REACTION_ADD({ optimistic, type, channelId, userId, emoji }: IReactionAdd) {
|
||||
MESSAGE_REACTION_ADD({ optimistic, type, channelId, userId, messageAuthorId, emoji }: IReactionAdd) {
|
||||
if (optimistic || type !== "MESSAGE_REACTION_ADD") return;
|
||||
if (settings.store.ignoreBots && UserStore.getUser(userId)?.bot) return;
|
||||
if (settings.store.ignoreBlocked && RelationshipStore.isBlocked(messageAuthorId)) return;
|
||||
if (channelId !== SelectedChannelStore.getChannelId()) return;
|
||||
|
||||
const name = emoji.name.toLowerCase();
|
||||
|
@ -78,7 +78,7 @@ export default definePlugin({
|
||||
</Avatar>
|
||||
<div className={ProfileListClasses.listRowContent}>
|
||||
<div className={ProfileListClasses.listName}>{getGroupDMName(c)}</div>
|
||||
<div className={GuildLabelClasses.guildNick}>{c.recipients.length} Members</div>
|
||||
<div className={GuildLabelClasses.guildNick}>{c.recipients.length + 1} Members</div>
|
||||
</div>
|
||||
</Clickable>
|
||||
));
|
||||
|
147
src/plugins/openInApp.ts
Normal file
147
src/plugins/openInApp.ts
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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 { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { showToast, Toasts } from "@webpack/common";
|
||||
import type { MouseEvent } from "react";
|
||||
|
||||
const ShortUrlMatcher = /^https:\/\/(spotify\.link|s\.team)\/.+$/;
|
||||
const SpotifyMatcher = /^https:\/\/open\.spotify\.com\/(track|album|artist|playlist|user)\/(.+)(?:\?.+?)?$/;
|
||||
const SteamMatcher = /^https:\/\/(steamcommunity\.com|(?:help|store)\.steampowered\.com)\/.+$/;
|
||||
const EpicMatcher = /^https:\/\/store\.epicgames\.com\/(.+)$/;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
spotify: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Open Spotify links in the Spotify app",
|
||||
default: true,
|
||||
},
|
||||
steam: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Open Steam links in the Steam app",
|
||||
default: true,
|
||||
},
|
||||
epic: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Open Epic Games links in the Epic Games Launcher",
|
||||
default: true,
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "OpenInApp",
|
||||
description: "Open Spotify, Steam and Epic Games URLs in their respective apps instead of your browser",
|
||||
authors: [Devs.Ven],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: '"MaskedLinkStore"',
|
||||
replacement: {
|
||||
match: /return ((\i)\.apply\(this,arguments\))(?=\}function \i.{0,200}\.trusted)/,
|
||||
replace: "return $self.handleLink(...arguments).then(handled => handled || $1)"
|
||||
}
|
||||
},
|
||||
// Make Spotify profile activity links open in app on web
|
||||
{
|
||||
find: "WEB_OPEN(",
|
||||
predicate: () => !IS_DISCORD_DESKTOP && settings.store.spotify,
|
||||
replacement: {
|
||||
match: /\i\.\i\.isProtocolRegistered\(\)(.{0,100})window.open/g,
|
||||
replace: "true$1VencordNative.native.openExternal"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".CONNECTED_ACCOUNT_VIEWED,",
|
||||
replacement: {
|
||||
match: /(?<=href:\i,onClick:function\(\)\{)(?=return \i=(\i)\.type,.{0,50}CONNECTED_ACCOUNT_VIEWED)/,
|
||||
replace: "$self.handleAccountView(arguments[0],$1.type,$1.id);"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
async handleLink(data: { href: string; }, event?: MouseEvent) {
|
||||
if (!data) return false;
|
||||
|
||||
let url = data.href;
|
||||
if (!IS_WEB && ShortUrlMatcher.test(url)) {
|
||||
event?.preventDefault();
|
||||
// CORS jumpscare
|
||||
url = await VencordNative.pluginHelpers.OpenInApp.resolveRedirect(url);
|
||||
}
|
||||
|
||||
spotify: {
|
||||
if (!settings.store.spotify) break spotify;
|
||||
|
||||
const match = SpotifyMatcher.exec(url);
|
||||
if (!match) break spotify;
|
||||
|
||||
const [, type, id] = match;
|
||||
VencordNative.native.openExternal(`spotify:${type}:${id}`);
|
||||
|
||||
event?.preventDefault();
|
||||
return true;
|
||||
}
|
||||
|
||||
steam: {
|
||||
if (!settings.store.steam) break steam;
|
||||
|
||||
if (!SteamMatcher.test(url)) break steam;
|
||||
|
||||
VencordNative.native.openExternal(`steam://openurl/${url}`);
|
||||
event?.preventDefault();
|
||||
|
||||
// Steam does not focus itself so show a toast so it's slightly less confusing
|
||||
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
|
||||
return true;
|
||||
}
|
||||
|
||||
epic: {
|
||||
if (!settings.store.epic) break epic;
|
||||
|
||||
const match = EpicMatcher.exec(url);
|
||||
if (!match) break epic;
|
||||
|
||||
VencordNative.native.openExternal(`com.epicgames.launcher://store/${match[1]}`);
|
||||
event?.preventDefault();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// in case short url didn't end up being something we can handle
|
||||
if (event?.defaultPrevented) {
|
||||
window.open(url, "_blank");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
handleAccountView(event: { preventDefault(): void; }, platformType: string, userId: string) {
|
||||
if (platformType === "spotify" && settings.store.spotify) {
|
||||
VencordNative.native.openExternal(`spotify:user:${userId}`);
|
||||
event.preventDefault();
|
||||
} else if (platformType === "steam" && settings.store.steam) {
|
||||
VencordNative.native.openExternal(`steam://openurl/https://steamcommunity.com/profiles/${userId}`);
|
||||
showToast("Opened link in Steam", Toasts.Type.SUCCESS);
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
@ -19,10 +19,12 @@
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Flex } from "@components/Flex";
|
||||
import { InfoIcon, OwnerCrownIcon } from "@components/Icons";
|
||||
import { getUniqueUsername } from "@utils/discord";
|
||||
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import { ContextMenu, FluxDispatcher, GuildMemberStore, Menu, PermissionsBits, Text, Tooltip, useEffect, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||
import type { Guild } from "discord-types/general";
|
||||
|
||||
import { settings } from "..";
|
||||
import { cl, getPermissionDescription, getPermissionString } from "../utils";
|
||||
import { PermissionAllowedIcon, PermissionDefaultIcon, PermissionDeniedIcon } from "./icons";
|
||||
|
||||
@ -108,7 +110,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||
<div
|
||||
className={cl("perms-list-item", { "perms-list-item-active": selectedItemIndex === index })}
|
||||
onContextMenu={e => {
|
||||
if (permission.type === PermissionType.Role)
|
||||
if ((settings.store as any).unsafeViewAsRole && permission.type === PermissionType.Role)
|
||||
ContextMenu.open(e, () => (
|
||||
<RoleContextMenu
|
||||
guild={guild}
|
||||
@ -135,7 +137,7 @@ function RolesAndUsersPermissionsComponent({ permissions, guild, modalProps, hea
|
||||
permission.type === PermissionType.Role
|
||||
? role?.name || "Unknown Role"
|
||||
: permission.type === PermissionType.User
|
||||
? user?.tag || "Unknown User"
|
||||
? (user && getUniqueUsername(user)) || "Unknown User"
|
||||
: (
|
||||
<Flex style={{ gap: "0.2em", justifyItems: "center" }}>
|
||||
@owner
|
||||
|
@ -63,6 +63,7 @@
|
||||
grid-area: list;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
border-right: 2px solid var(--background-modifier-active);
|
||||
}
|
||||
|
||||
@ -77,6 +78,15 @@
|
||||
padding: 8px 5px;
|
||||
cursor: pointer;
|
||||
width: 230px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-list-item:hover {
|
||||
background-color: var(--background-modifier-hover);
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-list-item-active {
|
||||
background-color: var(--background-modifier-selected);
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-list-item > div {
|
||||
@ -85,11 +95,6 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-list-item-active {
|
||||
background-color: var(--background-modifier-selected);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.vc-permviewer-perms-role-circle {
|
||||
border-radius: 50%;
|
||||
width: 12px;
|
||||
|
@ -52,7 +52,7 @@ export function CompactPronounsChatComponentWrapper({ message }: { message: Mess
|
||||
}
|
||||
|
||||
function PronounsChatComponent({ message }: { message: Message; }) {
|
||||
const result = useFormattedPronouns(message.author.id);
|
||||
const [result] = useFormattedPronouns(message.author.id);
|
||||
|
||||
return result
|
||||
? (
|
||||
@ -64,7 +64,7 @@ function PronounsChatComponent({ message }: { message: Message; }) {
|
||||
}
|
||||
|
||||
export function CompactPronounsChatComponent({ message }: { message: Message; }) {
|
||||
const result = useFormattedPronouns(message.author.id);
|
||||
const [result] = useFormattedPronouns(message.author.id);
|
||||
|
||||
return result
|
||||
? (
|
||||
|
@ -26,6 +26,11 @@ import { CompactPronounsChatComponentWrapper, PronounsChatComponentWrapper } fro
|
||||
import { useProfilePronouns } from "./pronoundbUtils";
|
||||
import { settings } from "./settings";
|
||||
|
||||
const PRONOUN_TOOLTIP_PATCH = {
|
||||
match: /text:(.{0,10}.Messages\.USER_PROFILE_PRONOUNS)(?=,)/,
|
||||
replace: '$& + (typeof vcPronounSource !== "undefined" ? ` (${vcPronounSource})` : "")'
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "PronounDB",
|
||||
authors: [Devs.Tyman, Devs.TheKodeToad, Devs.Ven],
|
||||
@ -50,18 +55,24 @@ export default definePlugin({
|
||||
// Patch the profile popout username header to use our pronoun hook instead of Discord's pronouns
|
||||
{
|
||||
find: ".userTagNoNickname",
|
||||
replacement: {
|
||||
match: /=(\i)\.pronouns/,
|
||||
replace: "=$self.useProfilePronouns($1.user.id)"
|
||||
}
|
||||
replacement: [
|
||||
{
|
||||
match: /,(\i)=(\i)\.pronouns/,
|
||||
replace: ",[$1,vcPronounSource]=$self.useProfilePronouns($2.user.id)"
|
||||
},
|
||||
PRONOUN_TOOLTIP_PATCH
|
||||
]
|
||||
},
|
||||
// Patch the profile modal username header to use our pronoun hook instead of Discord's pronouns
|
||||
{
|
||||
find: ".USER_PROFILE_ACTIVITY",
|
||||
replacement: {
|
||||
match: /\).showPronouns/,
|
||||
replace: ").showPronouns||true;const vcPronounce=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile)arguments[0].displayProfile.pronouns=vcPronounce"
|
||||
}
|
||||
replacement: [
|
||||
{
|
||||
match: /getGlobalName\(\i\);(?<=displayProfile.{0,200})/,
|
||||
replace: "$&const [vcPronounce,vcPronounSource]=$self.useProfilePronouns(arguments[0].user.id);if(arguments[0].displayProfile&&vcPronounce)arguments[0].displayProfile.pronouns=vcPronounce;"
|
||||
},
|
||||
PRONOUN_TOOLTIP_PATCH
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -19,17 +19,29 @@
|
||||
import { Settings } from "@api/Settings";
|
||||
import { VENCORD_USER_AGENT } from "@utils/constants";
|
||||
import { debounce } from "@utils/debounce";
|
||||
import { getCurrentChannel } from "@utils/discord";
|
||||
import { useAwaiter } from "@utils/react";
|
||||
import { findStoreLazy } from "@webpack";
|
||||
import { UserStore } from "@webpack/common";
|
||||
|
||||
import { settings } from "./settings";
|
||||
import { PronounCode, PronounMapping, PronounsResponse } from "./types";
|
||||
|
||||
const UserProfileStore = findStoreLazy("UserProfileStore");
|
||||
|
||||
type PronounsWithSource = [string | null, string];
|
||||
const EmptyPronouns: PronounsWithSource = [null, ""];
|
||||
|
||||
export const enum PronounsFormat {
|
||||
Lowercase = "LOWERCASE",
|
||||
Capitalized = "CAPITALIZED"
|
||||
}
|
||||
|
||||
export const enum PronounSource {
|
||||
PreferPDB,
|
||||
PreferDiscord
|
||||
}
|
||||
|
||||
// A map of cached pronouns so the same request isn't sent twice
|
||||
const cache: Record<string, PronounCode> = {};
|
||||
// A map of ids and callbacks that should be triggered on fetch
|
||||
@ -46,46 +58,63 @@ const bulkFetch = debounce(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
export function useFormattedPronouns(id: string): string | null {
|
||||
function getDiscordPronouns(id: string) {
|
||||
return (
|
||||
UserProfileStore.getGuildMemberProfile(id, getCurrentChannel()?.guild_id)?.pronouns
|
||||
|| UserProfileStore.getUserProfile(id)?.pronouns
|
||||
);
|
||||
}
|
||||
|
||||
export function useFormattedPronouns(id: string): PronounsWithSource {
|
||||
// Discord is so stupid you can put tons of newlines in pronouns
|
||||
const discordPronouns = getDiscordPronouns(id)?.trim().replace(NewLineRe, " ");
|
||||
|
||||
const [result] = useAwaiter(() => fetchPronouns(id), {
|
||||
fallbackValue: getCachedPronouns(id),
|
||||
onError: e => console.error("Fetching pronouns failed: ", e)
|
||||
});
|
||||
|
||||
// If the result is present and not "unspecified", and there is a mapping for the code, then return the mappings
|
||||
if (result && result !== "unspecified" && PronounMapping[result])
|
||||
return formatPronouns(result);
|
||||
if (settings.store.pronounSource === PronounSource.PreferDiscord && discordPronouns)
|
||||
return [discordPronouns, "Discord"];
|
||||
|
||||
return null;
|
||||
if (result && result !== "unspecified")
|
||||
return [formatPronouns(result), "PronounDB"];
|
||||
|
||||
return [discordPronouns, "Discord"];
|
||||
}
|
||||
|
||||
export function useProfilePronouns(id: string) {
|
||||
export function useProfilePronouns(id: string): PronounsWithSource {
|
||||
const pronouns = useFormattedPronouns(id);
|
||||
|
||||
if (!settings.store.showInProfile) return null;
|
||||
if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return null;
|
||||
if (!settings.store.showInProfile) return EmptyPronouns;
|
||||
if (!settings.store.showSelf && id === UserStore.getCurrentUser().id) return EmptyPronouns;
|
||||
|
||||
return pronouns;
|
||||
}
|
||||
|
||||
|
||||
const NewLineRe = /\n+/g;
|
||||
|
||||
// Gets the cached pronouns, if you're too impatient for a promise!
|
||||
export function getCachedPronouns(id: string): PronounCode | null {
|
||||
return cache[id] ?? null;
|
||||
export function getCachedPronouns(id: string): string | null {
|
||||
const cached = cache[id];
|
||||
if (cached && cached !== "unspecified") return cached;
|
||||
|
||||
return cached || null;
|
||||
}
|
||||
|
||||
// Fetches the pronouns for one id, returning a promise that resolves if it was cached, or once the request is completed
|
||||
export function fetchPronouns(id: string): Promise<PronounCode> {
|
||||
export function fetchPronouns(id: string): Promise<string> {
|
||||
return new Promise(res => {
|
||||
// If cached, return the cached pronouns
|
||||
if (id in cache) res(getCachedPronouns(id)!);
|
||||
const cached = getCachedPronouns(id);
|
||||
if (cached) return res(cached);
|
||||
|
||||
// If there is already a request added, then just add this callback to it
|
||||
else if (id in requestQueue) requestQueue[id].push(res);
|
||||
if (id in requestQueue) return requestQueue[id].push(res);
|
||||
|
||||
// If not already added, then add it and call the debounced function to make sure the request gets executed
|
||||
else {
|
||||
requestQueue[id] = [res];
|
||||
bulkFetch();
|
||||
}
|
||||
requestQueue[id] = [res];
|
||||
bulkFetch();
|
||||
});
|
||||
}
|
||||
|
||||
@ -116,7 +145,7 @@ async function bulkFetchPronouns(ids: string[]): Promise<PronounsResponse> {
|
||||
}
|
||||
}
|
||||
|
||||
export function formatPronouns(pronouns: PronounCode): string {
|
||||
export function formatPronouns(pronouns: string): string {
|
||||
const { pronounsFormat } = Settings.plugins.PronounDB as { pronounsFormat: PronounsFormat, enabled: boolean; };
|
||||
// For capitalized pronouns, just return the mapping (it is by default capitalized)
|
||||
if (pronounsFormat === PronounsFormat.Capitalized) return PronounMapping[pronouns];
|
||||
|
@ -19,7 +19,7 @@
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { OptionType } from "@utils/types";
|
||||
|
||||
import { PronounsFormat } from "./pronoundbUtils";
|
||||
import { PronounsFormat, PronounSource } from "./pronoundbUtils";
|
||||
|
||||
export const settings = definePluginSettings({
|
||||
pronounsFormat: {
|
||||
@ -37,6 +37,21 @@ export const settings = definePluginSettings({
|
||||
}
|
||||
]
|
||||
},
|
||||
pronounSource: {
|
||||
type: OptionType.SELECT,
|
||||
description: "Where to source pronouns from",
|
||||
options: [
|
||||
{
|
||||
label: "Prefer PronounDB, fall back to Discord",
|
||||
value: PronounSource.PreferPDB,
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Prefer Discord, fall back to PronounDB (might lead to inconsistency between pronouns in chat and profile)",
|
||||
value: PronounSource.PreferDiscord
|
||||
}
|
||||
]
|
||||
},
|
||||
showSelf: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Enable or disable showing pronouns for the current user",
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||
import { UserUtils } from "@webpack/common";
|
||||
|
||||
import settings from "./settings";
|
||||
@ -43,11 +44,19 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat
|
||||
switch (type) {
|
||||
case RelationshipType.FRIEND:
|
||||
if (settings.store.friends)
|
||||
notify(`${user.tag} removed you as a friend.`, user.getAvatarURL(undefined, undefined, false));
|
||||
notify(
|
||||
`${getUniqueUsername(user)} removed you as a friend.`,
|
||||
user.getAvatarURL(undefined, undefined, false),
|
||||
() => openUserProfile(user.id)
|
||||
);
|
||||
break;
|
||||
case RelationshipType.FRIEND_REQUEST:
|
||||
if (settings.store.friendRequestCancels)
|
||||
notify(`A friend request from ${user.tag} has been removed.`, user.getAvatarURL(undefined, undefined, false));
|
||||
notify(
|
||||
`A friend request from ${getUniqueUsername(user)} has been removed.`,
|
||||
user.getAvatarURL(undefined, undefined, false),
|
||||
() => openUserProfile(user.id)
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
import { DataStore, Notices } from "@api/index";
|
||||
import { showNotification } from "@api/Notifications";
|
||||
import { getUniqueUsername, openUserProfile } from "@utils/discord";
|
||||
import { ChannelStore, GuildMemberStore, GuildStore, RelationshipStore, UserStore, UserUtils } from "@webpack/common";
|
||||
|
||||
import settings from "./settings";
|
||||
@ -69,7 +70,11 @@ export async function syncAndRunChecks() {
|
||||
|
||||
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
||||
if (user)
|
||||
notify(`You are no longer friends with ${user.tag}.`, user.getAvatarURL(undefined, undefined, false));
|
||||
notify(
|
||||
`You are no longer friends with ${getUniqueUsername(user)}.`,
|
||||
user.getAvatarURL(undefined, undefined, false),
|
||||
() => openUserProfile(user.id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,20 +84,25 @@ export async function syncAndRunChecks() {
|
||||
|
||||
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
||||
if (user)
|
||||
notify(`Friend request from ${user.tag} has been revoked.`, user.getAvatarURL(undefined, undefined, false));
|
||||
notify(
|
||||
`Friend request from ${getUniqueUsername(user)} has been revoked.`,
|
||||
user.getAvatarURL(undefined, undefined, false),
|
||||
() => openUserProfile(user.id)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function notify(text: string, icon?: string) {
|
||||
export function notify(text: string, icon?: string, onClick?: () => void) {
|
||||
if (settings.store.notices)
|
||||
Notices.showNotice(text, "OK", () => Notices.popNotice());
|
||||
|
||||
showNotification({
|
||||
title: "Relationship Notifier",
|
||||
body: text,
|
||||
icon
|
||||
icon,
|
||||
onClick
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { openUserProfile } from "@utils/discord";
|
||||
import { classes } from "@utils/misc";
|
||||
import { LazyComponent } from "@utils/react";
|
||||
import { filters, findBulk } from "@webpack";
|
||||
@ -24,7 +25,7 @@ import { Alerts, moment, Timestamp, UserStore } from "@webpack/common";
|
||||
import { Review, ReviewType } from "../entities";
|
||||
import { deleteReview, reportReview } from "../reviewDbApi";
|
||||
import { settings } from "../settings";
|
||||
import { canDeleteReview, cl, openUserProfileModal, showToast } from "../utils";
|
||||
import { canDeleteReview, cl, showToast } from "../utils";
|
||||
import { DeleteButton, ReportButton } from "./MessageButton";
|
||||
import ReviewBadge from "./ReviewBadge";
|
||||
|
||||
@ -49,7 +50,7 @@ export default LazyComponent(() => {
|
||||
|
||||
return function ReviewComponent({ review, refetch }: { review: Review; refetch(): void; }) {
|
||||
function openModal() {
|
||||
openUserProfileModal(review.sender.discordID);
|
||||
openUserProfile(review.sender.discordID);
|
||||
}
|
||||
|
||||
function delReview() {
|
||||
|
@ -20,24 +20,13 @@ import { classNameFactory } from "@api/Styles";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { openModal } from "@utils/modal";
|
||||
import { findByProps } from "@webpack";
|
||||
import { FluxDispatcher, React, SelectedChannelStore, Toasts, UserUtils } from "@webpack/common";
|
||||
import { React, Toasts } from "@webpack/common";
|
||||
|
||||
import { Review, UserType } from "./entities";
|
||||
import { settings } from "./settings";
|
||||
|
||||
export const cl = classNameFactory("vc-rdb-");
|
||||
|
||||
export async function openUserProfileModal(userId: string) {
|
||||
await UserUtils.fetchUser(userId);
|
||||
|
||||
await FluxDispatcher.dispatch({
|
||||
type: "USER_PROFILE_MODAL_OPEN",
|
||||
userId,
|
||||
channelId: SelectedChannelStore.getChannelId(),
|
||||
analyticsLocation: "Explosive Hotel"
|
||||
});
|
||||
}
|
||||
|
||||
export function authorize(callback?: any) {
|
||||
const { OAuth2AuthorizeModal } = findByProps("OAuth2AuthorizeModal");
|
||||
|
||||
|
@ -147,6 +147,13 @@ function CompactConnectionComponent({ connection, theme }: { connection: Connect
|
||||
className="vc-user-connection"
|
||||
href={url}
|
||||
target="_blank"
|
||||
onClick={e => {
|
||||
if (Vencord.Plugins.isPluginEnabled("OpenInApp")) {
|
||||
const OpenInApp = Vencord.Plugins.plugins.OpenInApp as any as typeof import("../openInApp").default;
|
||||
// handleLink will .preventDefault() if applicable
|
||||
OpenInApp.handleLink(e.currentTarget, e);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{img}
|
||||
</a>
|
||||
|
@ -29,7 +29,7 @@ import type { Channel, Role } from "discord-types/general";
|
||||
|
||||
import HiddenChannelLockScreen, { setChannelBeginHeaderComponent } from "./components/HiddenChannelLockScreen";
|
||||
|
||||
const ChannelListClasses = findByPropsLazy("channelName", "subtitle", "modeMuted", "iconContainer");
|
||||
const ChannelListClasses = findByPropsLazy("channelEmoji", "unread", "icon");
|
||||
|
||||
export const VIEW_CHANNEL = 1n << 10n;
|
||||
const CONNECT = 1n << 20n;
|
||||
@ -342,32 +342,27 @@ export default definePlugin({
|
||||
]
|
||||
},
|
||||
{
|
||||
find: "Guild voice channel without guild id.",
|
||||
find: "useNotificationSettingsItem: channel cannot be undefined",
|
||||
replacement: [
|
||||
{
|
||||
// Render our HiddenChannelLockScreen component instead of the main stage channel component
|
||||
match: /Guild voice channel without guild id.+?children:(?<=(\i)\.getGuildId\(\).+?)(?=.{0,20}?}\)}function)/,
|
||||
match: /"124px".+?children:(?<=var (\i)=\i\.channel.+?)(?=.{0,20}?}\)}function)/,
|
||||
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel})?$self.HiddenChannelLockScreen(${channel}):`
|
||||
},
|
||||
{
|
||||
// Disable useless components for the HiddenChannelLockScreen of stage channels
|
||||
match: /render(?!Header).{0,30}?:(?<=(\i)\.getGuildId\(\).+?Guild voice channel without guild id.+?)/g,
|
||||
match: /render(?:BottomLeft|BottomCenter|BottomRight|ChatToasts):(?<=var (\i)=\i\.channel.+?)/g,
|
||||
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel})?null:`
|
||||
},
|
||||
// Prevent Discord from replacing our route if we aren't connected to the stage channel
|
||||
{
|
||||
match: /(?=!\i&&!\i&&!\i.{0,80}?(\i)\.getGuildId\(\).{0,50}?Guild voice channel without guild id)(?<=if\()/,
|
||||
replace: (_, channel) => `!$self.isHiddenChannel(${channel})&&`
|
||||
},
|
||||
{
|
||||
// Disable gradients for the HiddenChannelLockScreen of stage channels
|
||||
match: /Guild voice channel without guild id.+?disableGradients:(?<=(\i)\.getGuildId\(\).+?)/,
|
||||
match: /"124px".+?disableGradients:(?<=(\i)\.getGuildId\(\).+?)/,
|
||||
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel})||`
|
||||
},
|
||||
{
|
||||
// Disable strange styles applied to the header for the HiddenChannelLockScreen of stage channels
|
||||
match: /Guild voice channel without guild id.+?style:(?<=(\i)\.getGuildId\(\).+?)/,
|
||||
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel})?undefined:`
|
||||
match: /"124px".+?style:(?<=(\i)\.getGuildId\(\).+?)/,
|
||||
replace: (m, channel) => `${m}$self.isHiddenChannel(${channel})?void 0:`
|
||||
},
|
||||
{
|
||||
// Remove the divider and amount of users in stage channel components for the HiddenChannelLockScreen
|
||||
@ -376,7 +371,7 @@ export default definePlugin({
|
||||
},
|
||||
{
|
||||
// Remove the open chat button for the HiddenChannelLockScreen
|
||||
match: /"recents".+?null,(?=.+?channelId:(\i)\.id,showRequestToSpeakSidebar)/,
|
||||
match: /"recents".+?&&(?=\(.+?channelId:(\i)\.id,showRequestToSpeakSidebar)/,
|
||||
replace: (m, channel) => `${m}!$self.isHiddenChannel(${channel})&&`
|
||||
}
|
||||
],
|
||||
@ -419,6 +414,14 @@ export default definePlugin({
|
||||
match: /(?<=getChannels\(\i)(?=\))/,
|
||||
replace: ",true"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: '.displayName="NowPlayingViewStore"',
|
||||
replacement: {
|
||||
// Make active now voice states on hiddenl channels
|
||||
match: /(getVoiceStateForUser.{0,150}?)&&\i\.\i\.canWithPartialContext.{0,20}VIEW_CHANNEL.+?}\)(?=\?)/,
|
||||
replace: "$1"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@ -469,7 +472,7 @@ export default definePlugin({
|
||||
|
||||
HiddenChannelLockScreen: (channel: any) => <HiddenChannelLockScreen channel={channel} />,
|
||||
|
||||
LockIcon: () => (
|
||||
LockIcon: ErrorBoundary.wrap(() => (
|
||||
<svg
|
||||
className={ChannelListClasses.icon}
|
||||
height="18"
|
||||
@ -480,7 +483,7 @@ export default definePlugin({
|
||||
>
|
||||
<path className="shc-evenodd-fill-current-color" d="M17 11V7C17 4.243 14.756 2 12 2C9.242 2 7 4.243 7 7V11C5.897 11 5 11.896 5 13V20C5 21.103 5.897 22 7 22H17C18.103 22 19 21.103 19 20V13C19 11.896 18.103 11 17 11ZM12 18C11.172 18 10.5 17.328 10.5 16.5C10.5 15.672 11.172 15 12 15C12.828 15 13.5 15.672 13.5 16.5C13.5 17.328 12.828 18 12 18ZM15 11H9V7C9 5.346 10.346 4 12 4C13.654 4 15 5.346 15 7V11Z" />
|
||||
</svg>
|
||||
),
|
||||
), { noop: true }),
|
||||
|
||||
HiddenChannelIcon: ErrorBoundary.wrap(() => (
|
||||
<Tooltip text="Hidden Channel">
|
||||
|
@ -21,8 +21,8 @@ import "./spotifyStyles.css";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Flex } from "@components/Flex";
|
||||
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
|
||||
import { Link } from "@components/Link";
|
||||
import { debounce } from "@utils/debounce";
|
||||
import { openImageModal } from "@utils/discord";
|
||||
import { classes, copyWithToast } from "@utils/misc";
|
||||
import { ContextMenu, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common";
|
||||
|
||||
@ -231,7 +231,7 @@ function AlbumContextMenu({ track }: { track: Track; }) {
|
||||
id="view-cover"
|
||||
label="View Album Cover"
|
||||
// trolley
|
||||
action={() => (Vencord.Plugins.plugins.ViewIcons as any).openImage(track.album.image.url)}
|
||||
action={() => openImageModal(track.album.image.url)}
|
||||
icon={ImageIcon}
|
||||
/>
|
||||
<Menu.MenuControlItem
|
||||
@ -253,6 +253,16 @@ function AlbumContextMenu({ track }: { track: Track; }) {
|
||||
);
|
||||
}
|
||||
|
||||
function makeLinkProps(name: string, condition: unknown, path: string) {
|
||||
if (!condition) return {};
|
||||
|
||||
return {
|
||||
role: "link",
|
||||
onClick: () => SpotifyStore.openExternal(path),
|
||||
onContextMenu: makeContextMenu(name, path)
|
||||
} satisfies React.HTMLAttributes<HTMLElement>;
|
||||
}
|
||||
|
||||
function Info({ track }: { track: Track; }) {
|
||||
const img = track?.album?.image;
|
||||
|
||||
@ -288,12 +298,8 @@ function Info({ track }: { track: Track; }) {
|
||||
variant="text-sm/semibold"
|
||||
id={cl("song-title")}
|
||||
className={cl("ellipoverflow")}
|
||||
role={track.id ? "link" : undefined}
|
||||
title={track.name}
|
||||
onClick={track.id ? () => {
|
||||
SpotifyStore.openExternal(`/track/${track.id}`);
|
||||
} : void 0}
|
||||
onContextMenu={track.id ? makeContextMenu("Song", `/track/${track.id}`) : void 0}
|
||||
{...makeLinkProps("Song", track.id, `/track/${track.id}`)}
|
||||
>
|
||||
{track.name}
|
||||
</Forms.FormText>
|
||||
@ -302,16 +308,14 @@ function Info({ track }: { track: Track; }) {
|
||||
by
|
||||
{track.artists.map((a, i) => (
|
||||
<React.Fragment key={a.name}>
|
||||
<Link
|
||||
<span
|
||||
className={cl("artist")}
|
||||
disabled={!a.id}
|
||||
href={`https://open.spotify.com/artist/${a.id}`}
|
||||
style={{ fontSize: "inherit" }}
|
||||
title={a.name}
|
||||
onContextMenu={makeContextMenu("Artist", `/artist/${a.id}`)}
|
||||
{...makeLinkProps("Artist", a.id, `/artist/${a.id}`)}
|
||||
>
|
||||
{a.name}
|
||||
</Link>
|
||||
</span>
|
||||
{i !== track.artists.length - 1 && <span className={cl("comma")}>{", "}</span>}
|
||||
</React.Fragment>
|
||||
))}
|
||||
@ -320,17 +324,15 @@ function Info({ track }: { track: Track; }) {
|
||||
{track.album.name && (
|
||||
<Forms.FormText variant="text-sm/normal" className={cl("ellipoverflow")}>
|
||||
on
|
||||
<Link id={cl("album-title")}
|
||||
href={`https://open.spotify.com/album/${track.album.id}`}
|
||||
target="_blank"
|
||||
<span
|
||||
id={cl("album-title")}
|
||||
className={cl("album")}
|
||||
disabled={!track.album.id}
|
||||
style={{ fontSize: "inherit" }}
|
||||
title={track.album.name}
|
||||
onContextMenu={makeContextMenu("Album", `/album/${track.album.id}`)}
|
||||
{...makeLinkProps("Album", track.album.id, `/album/${track.album.id}`)}
|
||||
>
|
||||
{track.album.name}
|
||||
</Link>
|
||||
</span>
|
||||
</Forms.FormText>
|
||||
)}
|
||||
</div>
|
||||
|
@ -89,7 +89,7 @@ export const SpotifyStore = proxyLazy(() => {
|
||||
public isSettingPosition = false;
|
||||
|
||||
public openExternal(path: string) {
|
||||
const url = Settings.plugins.SpotifyControls.useSpotifyUris
|
||||
const url = Settings.plugins.SpotifyControls.useSpotifyUris || Vencord.Plugins.isPluginEnabled("OpenInApp")
|
||||
? "spotify:" + path.replaceAll("/", (_, idx) => idx === 0 ? "" : ":")
|
||||
: "https://open.spotify.com" + path;
|
||||
|
||||
|
@ -131,8 +131,8 @@
|
||||
color: var(--header-secondary);
|
||||
}
|
||||
|
||||
.vc-spotify-artist:hover,
|
||||
#vc-spotify-album-title:hover,
|
||||
.vc-spotify-artist[role="link"]:hover,
|
||||
#vc-spotify-album-title[role="link"]:hover,
|
||||
#vc-spotify-song-title[role="link"]:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
|
@ -19,13 +19,13 @@
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { openUserProfile } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { GuildMemberStore, React, RelationshipStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { GuildMemberStore, React, RelationshipStore } from "@webpack/common";
|
||||
import { User } from "discord-types/general";
|
||||
|
||||
const Avatar = findByCodeLazy(".typingIndicatorRef", "svg");
|
||||
const openProfile = findByCodeLazy("friendToken", "USER_PROFILE_MODAL_OPEN");
|
||||
|
||||
const settings = definePluginSettings({
|
||||
showAvatars: {
|
||||
@ -64,15 +64,7 @@ const TypingUser = ErrorBoundary.wrap(function ({ user, guildId }: Props) {
|
||||
<strong
|
||||
role="button"
|
||||
onClick={() => {
|
||||
openProfile({
|
||||
userId: user.id,
|
||||
guildId,
|
||||
channelId: SelectedChannelStore.getChannelId(),
|
||||
analyticsLocation: {
|
||||
page: guildId ? "Guild Channel" : "DM Channel",
|
||||
section: "Profile Popout"
|
||||
}
|
||||
});
|
||||
openUserProfile(user.id);
|
||||
}}
|
||||
style={{
|
||||
display: "grid",
|
||||
|
@ -65,6 +65,7 @@ const replacements = [
|
||||
["stupid", "baka"],
|
||||
["what", "nani"],
|
||||
["meow", "nya~"],
|
||||
["hello", "hewwo"],
|
||||
];
|
||||
|
||||
const settings = definePluginSettings({
|
||||
|
@ -24,7 +24,7 @@ import definePlugin from "@utils/types";
|
||||
import { findByCodeLazy } from "@webpack";
|
||||
import { UserStore, useState } from "@webpack/common";
|
||||
import type { User } from "discord-types/general";
|
||||
import type { ComponentType } from "react";
|
||||
import type { ComponentType, ReactNode } from "react";
|
||||
|
||||
const fetching = new Set<string>();
|
||||
const queue = new Queue(5);
|
||||
@ -36,7 +36,7 @@ interface MentionProps {
|
||||
channelId?: string;
|
||||
content: any;
|
||||
};
|
||||
parse: (content: any, props: MentionProps["props"]) => string[];
|
||||
parse: (content: any, props: MentionProps["props"]) => ReactNode;
|
||||
props: {
|
||||
key: string;
|
||||
formatInline: boolean;
|
||||
@ -72,10 +72,10 @@ function MentionWrapper({ data, UserMention, RoleMention, parse, props }: Mentio
|
||||
>
|
||||
<span
|
||||
onMouseEnter={() => {
|
||||
const mention = children?.[0];
|
||||
const mention = children?.[0]?.props?.children;
|
||||
if (typeof mention !== "string") return;
|
||||
|
||||
const id = mention.match(/<@(\d+)>/)?.[1];
|
||||
const id = mention.match(/<@!?(\d+)>/)?.[1];
|
||||
if (!id) return;
|
||||
|
||||
if (fetching.has(id))
|
||||
|
@ -156,6 +156,8 @@ export default definePlugin({
|
||||
const myChanId = SelectedChannelStore.getVoiceChannelId();
|
||||
const myId = UserStore.getCurrentUser().id;
|
||||
|
||||
if (ChannelStore.getChannel(myChanId!)?.type === 13 /* Stage Channel */) return;
|
||||
|
||||
for (const state of voiceStates) {
|
||||
const { userId, channelId, oldChannelId } = state;
|
||||
const isMe = userId === myId;
|
||||
|
@ -35,7 +35,7 @@ interface UserContextProps {
|
||||
}
|
||||
|
||||
interface GuildContextProps {
|
||||
guild: Guild;
|
||||
guild?: Guild;
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
@ -100,7 +100,8 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
||||
action={() => openImage(BannerStore.getGuildMemberAvatarURLSimple({
|
||||
userId: user.id,
|
||||
avatar: memberAvatar,
|
||||
guildId
|
||||
guildId,
|
||||
canAnimate: true
|
||||
}, true))}
|
||||
icon={ImageIcon}
|
||||
/>
|
||||
@ -109,7 +110,10 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
||||
));
|
||||
};
|
||||
|
||||
const GuildContext: NavContextMenuPatchCallback = (children, { guild: { id, icon, banner } }: GuildContextProps) => () => {
|
||||
const GuildContext: NavContextMenuPatchCallback = (children, { guild }: GuildContextProps) => () => {
|
||||
if(!guild) return;
|
||||
|
||||
const { id, icon, banner } = guild;
|
||||
if (!banner && !icon) return;
|
||||
|
||||
children.splice(-1, 0, (
|
||||
@ -181,8 +185,8 @@ export default definePlugin({
|
||||
// style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl,
|
||||
match: /style:\{(?=backgroundImage:(\i&&\i)\?"url\("\.concat\((\i),)/,
|
||||
replace:
|
||||
// onClick: () => shouldShowBanner && openImage(bannerUrl), style: { cursor: shouldShowBanner ? "pointer" : void 0,
|
||||
'onClick:()=>$1&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
|
||||
// onClick: () => shouldShowBanner && ev.target.style.backgroundImage && openImage(bannerUrl), style: { cursor: shouldShowBanner ? "pointer" : void 0,
|
||||
'onClick:ev=>$1&&ev.target.style.backgroundImage&&$self.openImage($2),style:{cursor:$1?"pointer":void 0,'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -47,9 +47,10 @@ const settings = definePluginSettings({
|
||||
|
||||
export default definePlugin({
|
||||
name: "WebContextMenus",
|
||||
description: "Re-adds context menus missing in the web version of Discord: Images, ChatInputBar, Links, 'Copy Link', 'Open Link', 'Copy Image', 'Save Image'",
|
||||
description: "Re-adds context menus missing in the web version of Discord: Links & Images (Copy/Open Link/Image), Text Area (Copy, Cut, Paste, SpellCheck)",
|
||||
authors: [Devs.Ven],
|
||||
enabledByDefault: true,
|
||||
required: IS_VENCORD_DESKTOP,
|
||||
|
||||
settings,
|
||||
|
||||
@ -146,36 +147,30 @@ export default definePlugin({
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ':"command-suggestions"',
|
||||
find: 'navId:"textarea-context"',
|
||||
all: true,
|
||||
predicate: () => settings.store.addBack,
|
||||
replacement: [
|
||||
{
|
||||
// desktopOnlyEntries = makeEntries(), spellcheckChildren = desktopOnlyEntries[0], languageChildren = desktopOnlyEntries[1]
|
||||
match: /\i=.{0,30}text:\i,target:\i,onHeightUpdate:\i\}\),2\),(\i)=\i\[0\],(\i)=\i\[1\]/,
|
||||
// set spellcheckChildren & languageChildren to empty arrays, so just in case patch 3 fails, we don't
|
||||
// reference undefined variables
|
||||
replace: "$1=[],$2=[]",
|
||||
},
|
||||
{
|
||||
// if (!IS_DESKTOP) return null;
|
||||
match: /if\(!\i\.\i\)return null;/,
|
||||
replace: ""
|
||||
},
|
||||
{
|
||||
// do not add menu items for entries removed in patch 1. Using a lookbehind for group 1 is slow,
|
||||
// so just capture and add back
|
||||
match: /("submit-button".+?)(\(0,\i\.jsx\)\(\i\.MenuGroup,\{children:\i\}\),){2}/,
|
||||
replace: "$1"
|
||||
},
|
||||
{
|
||||
// Change calls to DiscordNative.clipboard to us instead
|
||||
match: /\b\i\.default\.(copy|cut|paste)/g,
|
||||
replace: "$self.$1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
find: '"add-to-dictionary"',
|
||||
predicate: () => settings.store.addBack,
|
||||
replacement: {
|
||||
match: /var \i=\i\.text,/,
|
||||
replace: "return [null,null];$&"
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Maybe add spellcheck for VencordDesktop
|
||||
],
|
||||
|
||||
async copyImage(url: string) {
|
||||
|
79
src/plugins/webKeybinds.vencordDesktop.ts
Normal file
79
src/plugins/webKeybinds.vencordDesktop.ts
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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 { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findLazy, mapMangledModuleLazy } from "@webpack";
|
||||
import { ComponentDispatch, FluxDispatcher, NavigationRouter, SelectedGuildStore, SettingsRouter } from "@webpack/common";
|
||||
|
||||
const GuildNavBinds = mapMangledModuleLazy("mod+alt+down", {
|
||||
CtrlTab: m => m.binds?.at(-1) === "ctrl+tab",
|
||||
CtrlShiftTab: m => m.binds?.at(-1) === "ctrl+shift+tab",
|
||||
});
|
||||
|
||||
const DigitBinds = findLazy(m => m.binds?.[0] === "mod+1");
|
||||
|
||||
export default definePlugin({
|
||||
name: "WebKeybinds",
|
||||
description: "Re-adds keybinds missing in the web version of Discord: ctrl+t, ctrl+shift+t, ctrl+tab, ctrl+shift+tab, ctrl+1-9, ctrl+,",
|
||||
authors: [Devs.Ven],
|
||||
enabledByDefault: true,
|
||||
|
||||
onKey(e: KeyboardEvent) {
|
||||
const hasCtrl = e.ctrlKey || (e.metaKey && navigator.platform.includes("Mac"));
|
||||
|
||||
if (hasCtrl) switch (e.key) {
|
||||
case "t":
|
||||
case "T":
|
||||
e.preventDefault();
|
||||
if (e.shiftKey) {
|
||||
if (SelectedGuildStore.getGuildId()) NavigationRouter.transitionToGuild("@me");
|
||||
ComponentDispatch.safeDispatch("TOGGLE_DM_CREATE");
|
||||
} else {
|
||||
FluxDispatcher.dispatch({
|
||||
type: "QUICKSWITCHER_SHOW",
|
||||
query: "",
|
||||
queryMode: null
|
||||
});
|
||||
}
|
||||
break;
|
||||
case ",":
|
||||
e.preventDefault();
|
||||
SettingsRouter.open("My Account");
|
||||
break;
|
||||
case "Tab":
|
||||
const handler = e.shiftKey ? GuildNavBinds.CtrlShiftTab : GuildNavBinds.CtrlTab;
|
||||
handler.action(e);
|
||||
break;
|
||||
default:
|
||||
if (e.key >= "1" && e.key <= "9") {
|
||||
e.preventDefault();
|
||||
DigitBinds.action(e, `mod+${e.key}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
start() {
|
||||
document.addEventListener("keydown", this.onKey);
|
||||
},
|
||||
|
||||
stop() {
|
||||
document.removeEventListener("keydown", this.onKey);
|
||||
}
|
||||
});
|
@ -44,7 +44,10 @@ const settings = definePluginSettings({
|
||||
],
|
||||
description: "Choose the greet mode"
|
||||
}
|
||||
});
|
||||
}).withPrivateSettings<{
|
||||
multiGreetChoices?: string[];
|
||||
unholyMultiGreetEnabled?: boolean;
|
||||
}>();
|
||||
|
||||
const MessageActions = findByPropsLazy("sendGreetMessage");
|
||||
|
||||
@ -73,7 +76,7 @@ function greet(channel: Channel, message: Message, stickers: string[]) {
|
||||
|
||||
|
||||
function GreetMenu({ stickers, channel, message }: { stickers: Sticker[], message: Message, channel: Channel; }) {
|
||||
const s = settings.use(["greetMode", "multiGreetChoices"] as any) as { greetMode: GreetMode, multiGreetChoices: string[]; };
|
||||
const s = settings.use(["greetMode", "multiGreetChoices"]);
|
||||
const { greetMode, multiGreetChoices = [] } = s;
|
||||
|
||||
return (
|
||||
@ -112,7 +115,7 @@ function GreetMenu({ stickers, channel, message }: { stickers: Sticker[], messag
|
||||
))}
|
||||
</Menu.MenuGroup>
|
||||
|
||||
{!(settings.store as any).unholyMultiGreetEnabled ? null : (
|
||||
{!settings.store.unholyMultiGreetEnabled ? null : (
|
||||
<>
|
||||
<Menu.MenuSeparator />
|
||||
|
||||
|
@ -30,4 +30,6 @@ export const enum IpcEvents {
|
||||
UPDATE = "VencordUpdate",
|
||||
BUILD = "VencordBuild",
|
||||
OPEN_MONACO_EDITOR = "VencordOpenMonacoEditor",
|
||||
|
||||
OPEN_IN_APP__RESOLVE_REDIRECT = "VencordOIAResolveRedirect",
|
||||
}
|
||||
|
@ -17,9 +17,9 @@
|
||||
*/
|
||||
|
||||
import { MessageObject } from "@api/MessageEvents";
|
||||
import { findByPropsLazy, findLazy } from "@webpack";
|
||||
import { ChannelStore, ComponentDispatch, GuildStore, MaskedLink, ModalImageClasses, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
|
||||
import { Guild, Message } from "discord-types/general";
|
||||
import { findByCodeLazy, findByPropsLazy, findLazy } from "@webpack";
|
||||
import { ChannelStore, ComponentDispatch, GuildStore, MaskedLink, ModalImageClasses, PrivateChannelsStore, SelectedChannelStore, SelectedGuildStore, UserUtils } from "@webpack/common";
|
||||
import { Guild, Message, User } from "discord-types/general";
|
||||
|
||||
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
||||
|
||||
@ -99,3 +99,28 @@ export function openImageModal(url: string, props?: Partial<React.ComponentProps
|
||||
</ModalRoot>
|
||||
));
|
||||
}
|
||||
|
||||
const openProfile = findByCodeLazy("friendToken", "USER_PROFILE_MODAL_OPEN");
|
||||
|
||||
export async function openUserProfile(id: string) {
|
||||
const user = await UserUtils.fetchUser(id);
|
||||
if (!user) throw new Error("No such user: " + id);
|
||||
|
||||
const guildId = SelectedGuildStore.getGuildId();
|
||||
openProfile({
|
||||
userId: id,
|
||||
guildId,
|
||||
channelId: SelectedChannelStore.getChannelId(),
|
||||
analyticsLocation: {
|
||||
page: guildId ? "Guild Channel" : "DM Channel",
|
||||
section: "Profile Popout"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique username for a user. Returns user.username for pomelo people, user.tag otherwise
|
||||
*/
|
||||
export function getUniqueUsername(user: User) {
|
||||
return user.discriminator === "0" ? user.username : user.tag;
|
||||
}
|
||||
|
@ -31,4 +31,5 @@ export * from "./onceDefined";
|
||||
export * from "./onlyOnce";
|
||||
export * from "./patches";
|
||||
export * from "./Queue";
|
||||
export * from "./react";
|
||||
export * from "./text";
|
||||
|
@ -27,8 +27,8 @@ const unconfigurable = ["arguments", "caller", "prototype"];
|
||||
|
||||
const handler: ProxyHandler<any> = {};
|
||||
|
||||
const GET_KEY = Symbol.for("vencord.lazy.get");
|
||||
const CACHED_KEY = Symbol.for("vencord.lazy.cached");
|
||||
const kGET = Symbol.for("vencord.lazy.get");
|
||||
const kCACHE = Symbol.for("vencord.lazy.cached");
|
||||
|
||||
for (const method of [
|
||||
"apply",
|
||||
@ -46,11 +46,11 @@ for (const method of [
|
||||
"setPrototypeOf"
|
||||
]) {
|
||||
handler[method] =
|
||||
(target: any, ...args: any[]) => Reflect[method](target[GET_KEY](), ...args);
|
||||
(target: any, ...args: any[]) => Reflect[method](target[kGET](), ...args);
|
||||
}
|
||||
|
||||
handler.ownKeys = target => {
|
||||
const v = target[GET_KEY]();
|
||||
const v = target[kGET]();
|
||||
const keys = Reflect.ownKeys(v);
|
||||
for (const key of unconfigurable) {
|
||||
if (!keys.includes(key)) keys.push(key);
|
||||
@ -62,7 +62,7 @@ handler.getOwnPropertyDescriptor = (target, p) => {
|
||||
if (typeof p === "string" && unconfigurable.includes(p))
|
||||
return Reflect.getOwnPropertyDescriptor(target, p);
|
||||
|
||||
const descriptor = Reflect.getOwnPropertyDescriptor(target[GET_KEY](), p);
|
||||
const descriptor = Reflect.getOwnPropertyDescriptor(target[kGET](), p);
|
||||
|
||||
if (descriptor) Object.defineProperty(target, p, descriptor);
|
||||
return descriptor;
|
||||
@ -72,15 +72,22 @@ handler.getOwnPropertyDescriptor = (target, p) => {
|
||||
* Wraps the result of {@see makeLazy} in a Proxy you can consume as if it wasn't lazy.
|
||||
* On first property access, the lazy is evaluated
|
||||
* @param factory lazy factory
|
||||
* @param attempts how many times to try to evaluate the lazy before giving up
|
||||
* @returns Proxy
|
||||
*
|
||||
* Note that the example below exists already as an api, see {@link findByPropsLazy}
|
||||
* @example const mod = proxyLazy(() => findByProps("blah")); console.log(mod.blah);
|
||||
*/
|
||||
export function proxyLazy<T>(factory: () => T): T {
|
||||
const proxyDummy: { (): void;[CACHED_KEY]?: T;[GET_KEY](): T; } = Object.assign(function () { }, {
|
||||
[CACHED_KEY]: void 0,
|
||||
[GET_KEY]: () => proxyDummy[CACHED_KEY] ??= factory(),
|
||||
export function proxyLazy<T>(factory: () => T, attempts = 5): T {
|
||||
let tries = 0;
|
||||
const proxyDummy = Object.assign(function () { }, {
|
||||
[kCACHE]: void 0 as T | undefined,
|
||||
[kGET]() {
|
||||
if (!proxyDummy[kCACHE] && attempts > tries++) {
|
||||
proxyDummy[kCACHE] = factory();
|
||||
}
|
||||
return proxyDummy[kCACHE];
|
||||
}
|
||||
});
|
||||
|
||||
return new Proxy(proxyDummy, handler) as any;
|
||||
|
@ -41,10 +41,10 @@ export async function importSettings(data: string) {
|
||||
throw new Error("Invalid Settings. Is this even a Vencord Settings file?");
|
||||
}
|
||||
|
||||
export async function exportSettings() {
|
||||
export async function exportSettings({ minify }: { minify?: boolean; } = {}) {
|
||||
const settings = JSON.parse(VencordNative.settings.get());
|
||||
const quickCss = await VencordNative.quickCss.get();
|
||||
return JSON.stringify({ settings, quickCss }, null, 4);
|
||||
return JSON.stringify({ settings, quickCss }, null, minify ? undefined : 4);
|
||||
}
|
||||
|
||||
export async function downloadSettingsBackup() {
|
||||
@ -121,8 +121,8 @@ export async function uploadSettingsBackup(showToast = true): Promise<void> {
|
||||
// Cloud settings
|
||||
const cloudSettingsLogger = new Logger("Cloud:Settings", "#39b7e0");
|
||||
|
||||
export async function putCloudSettings() {
|
||||
const settings = await exportSettings();
|
||||
export async function putCloudSettings(manual?: boolean) {
|
||||
const settings = await exportSettings({ minify: true });
|
||||
|
||||
try {
|
||||
const res = await fetch(new URL("/v1/settings", getCloudUrl()), {
|
||||
@ -149,6 +149,14 @@ export async function putCloudSettings() {
|
||||
VencordNative.settings.set(JSON.stringify(PlainSettings, null, 4));
|
||||
|
||||
cloudSettingsLogger.info("Settings uploaded to cloud successfully");
|
||||
|
||||
if (manual) {
|
||||
showNotification({
|
||||
title: "Cloud Settings",
|
||||
body: "Synchronized settings to the cloud!",
|
||||
noPersist: true,
|
||||
});
|
||||
}
|
||||
} catch (e: any) {
|
||||
cloudSettingsLogger.error("Failed to sync up", e);
|
||||
showNotification({
|
||||
|
@ -260,25 +260,29 @@ type SettingsStore<D extends SettingsDefinition> = {
|
||||
};
|
||||
|
||||
/** An instance of defined plugin settings */
|
||||
export interface DefinedSettings<D extends SettingsDefinition = SettingsDefinition, C extends SettingsChecks<D> = {}> {
|
||||
export interface DefinedSettings<
|
||||
Def extends SettingsDefinition = SettingsDefinition,
|
||||
Checks extends SettingsChecks<Def> = {},
|
||||
PrivateSettings extends object = {}
|
||||
> {
|
||||
/** Shorthand for `Vencord.Settings.plugins.PluginName`, but with typings */
|
||||
store: SettingsStore<D>;
|
||||
store: SettingsStore<Def> & PrivateSettings;
|
||||
/**
|
||||
* React hook for getting the settings for this plugin
|
||||
* @param filter optional filter to avoid rerenders for irrelavent settings
|
||||
*/
|
||||
use<F extends Extract<keyof D, string>>(filter?: F[]): Pick<SettingsStore<D>, F>;
|
||||
use<F extends Extract<keyof Def | keyof PrivateSettings, string>>(filter?: F[]): Pick<SettingsStore<Def> & PrivateSettings, F>;
|
||||
/** Definitions of each setting */
|
||||
def: D;
|
||||
def: Def;
|
||||
/** Setting methods with return values that could rely on other settings */
|
||||
checks: C;
|
||||
checks: Checks;
|
||||
/**
|
||||
* Name of the plugin these settings belong to,
|
||||
* will be an empty string until plugin is initialized
|
||||
*/
|
||||
pluginName: string;
|
||||
|
||||
withPrivateSettings<T>(): this & { store: T; };
|
||||
withPrivateSettings<T extends object>(): DefinedSettings<Def, Checks, T>;
|
||||
}
|
||||
|
||||
export type PartialExcept<T, R extends keyof T> = Partial<T> & Required<Pick<T, R>>;
|
||||
|
9
src/webpack/common/types/stores.d.ts
vendored
9
src/webpack/common/types/stores.d.ts
vendored
@ -20,14 +20,23 @@ import { Channel } from "discord-types/general";
|
||||
|
||||
import { FluxDispatcher, FluxEvents } from "./utils";
|
||||
|
||||
type GenericFunction = (...args: any[]) => any;
|
||||
|
||||
export class FluxStore {
|
||||
constructor(dispatcher: FluxDispatcher, eventHandlers?: Partial<Record<FluxEvents, (data: any) => void>>);
|
||||
|
||||
addChangeListener(callback: () => void): void;
|
||||
addReactChangeListener(callback: () => void): void;
|
||||
removeChangeListener(callback: () => void): void;
|
||||
removeReactChangeListener(callback: () => void): void;
|
||||
emitChange(): void;
|
||||
getDispatchToken(): string;
|
||||
getName(): string;
|
||||
initialize(): void;
|
||||
initializeIfNeeded(): void;
|
||||
registerActionHandlers: GenericFunction;
|
||||
syncWith: GenericFunction;
|
||||
waitFor: GenericFunction;
|
||||
__getLocalVars(): Record<string, any>;
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,17 @@ export const Toasts = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a simple toast. If you need more options, use Toasts.show manually
|
||||
*/
|
||||
export function showToast(message: string, type = ToastType.MESSAGE) {
|
||||
Toasts.show({
|
||||
id: Toasts.genId(),
|
||||
message,
|
||||
type
|
||||
});
|
||||
}
|
||||
|
||||
export const UserUtils = {
|
||||
fetchUser: findByCodeLazy(".USER(", "getUser") as (id: string) => Promise<User>,
|
||||
};
|
||||
|
Reference in New Issue
Block a user