mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-23 21:37:03 -04:00
Updates
This commit is contained in:
parent
75fac79ad1
commit
deceb2ba97
13 changed files with 186 additions and 58 deletions
|
@ -37,12 +37,13 @@ export const settings = definePluginSettings({
|
|||
|
||||
export default definePlugin({
|
||||
name: "Anammox",
|
||||
description: "Remove Some Discord Settings",
|
||||
description: "A microbial process that plays an important part in the nitrogen cycle",
|
||||
authors: [Devs.Kyuuhachi],
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{ // Above DMs, mouse nav
|
||||
{
|
||||
// Above DMs, mouse nav
|
||||
find: 'tutorialId:"direct-messages"',
|
||||
replacement: [
|
||||
{
|
||||
|
@ -56,7 +57,8 @@ export default definePlugin({
|
|||
],
|
||||
predicate: () => settings.store.dms,
|
||||
},
|
||||
{ // Above DMs, keyboard nav
|
||||
{
|
||||
// Above DMs, keyboard nav
|
||||
find: ".hasLibraryApplication()&&!",
|
||||
replacement: [
|
||||
{
|
||||
|
@ -70,7 +72,8 @@ export default definePlugin({
|
|||
],
|
||||
predicate: () => settings.store.dms,
|
||||
},
|
||||
{ // Settings, sidebar
|
||||
{
|
||||
// Settings, sidebar
|
||||
find: "Messages.BILLING_SETTINGS",
|
||||
replacement: [
|
||||
{
|
||||
|
@ -84,23 +87,26 @@ export default definePlugin({
|
|||
],
|
||||
predicate: () => settings.store.billing,
|
||||
},
|
||||
{ // Gift button
|
||||
find: 'Messages.PREMIUM_GIFT_BUTTON_LABEL,"aria-haspopup":"dialog",onClick:',
|
||||
{
|
||||
// Gift button
|
||||
find: ".gifts)||void 0===",
|
||||
replacement: {
|
||||
match: /if\(\i\)return null;/,
|
||||
replace: "return null;",
|
||||
match: /let\{disabled:\i,channel:\i\}=\i/,
|
||||
replace: "return null;$&",
|
||||
},
|
||||
predicate: () => settings.store.gift,
|
||||
},
|
||||
{ // Emoji list
|
||||
{
|
||||
// Emoji list
|
||||
find: "Messages.EMOJI_PICKER_CREATE_EMOJI_TITLE,size:",
|
||||
replacement: {
|
||||
match: /(\i)=\i\|\|!\i&&\i.\i\i.isEmojiCategoryNitroLocked\(\{[^}]*\}\);/,
|
||||
match: /(\i)=\i\|\|!\i&&\i.\i.isEmojiCategoryNitroLocked\(\{[^}]*\}\);/,
|
||||
replace: "$&$1||"
|
||||
},
|
||||
predicate: () => settings.store.emojiList,
|
||||
},
|
||||
{ // Emoji category list
|
||||
{
|
||||
// Emoji category list
|
||||
find: "Messages.EMOJI_CATEGORY_TOP_GUILD_EMOJI.format({",
|
||||
replacement: {
|
||||
match: /(?<=(\i)\.unshift\((\i)\):)(?=\1\.push\(\2\))/,
|
|
@ -163,7 +163,8 @@ function ChannelTabContent(props: ChannelTabsProps & {
|
|||
{!showStatusIndicators && <TypingIndicator isTyping={isTyping} />}
|
||||
</>
|
||||
);
|
||||
} else { // Group DM
|
||||
} else {
|
||||
// Group DM
|
||||
return (
|
||||
<>
|
||||
<ChannelIcon channel={channel} />
|
||||
|
|
|
@ -25,7 +25,7 @@ const mimeTypes = {
|
|||
mov: "video/quicktime",
|
||||
};
|
||||
|
||||
const formatDimension = (value) => value % 1 === 0 ? value : value.toFixed(2);
|
||||
const formatDimension = value => value % 1 === 0 ? value : value.toFixed(2);
|
||||
|
||||
function getMimeType(extension: string | undefined): [boolean, string] {
|
||||
if (!extension) return [false, ""];
|
||||
|
@ -389,7 +389,7 @@ export default definePlugin({
|
|||
|
||||
start() {
|
||||
let timeout: number | undefined;
|
||||
let previewDiv: HTMLDivElement | null = null;
|
||||
const previewDiv: HTMLDivElement | null = null;
|
||||
|
||||
function initialScan() {
|
||||
const appContainer = document.querySelector('[class*="app-"]');
|
||||
|
|
|
@ -55,4 +55,4 @@ video {
|
|||
.dimensions-displaying,
|
||||
.dimensions-original {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,14 @@
|
|||
|
||||
import "./style.css";
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { getUserSettingLazy } from "@api/UserSettings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { proxyLazy } from "@utils/lazy";
|
||||
import definePlugin from "@utils/types";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findComponentByCodeLazy } from "@webpack";
|
||||
import { ChannelStore, Forms, MessageStore, RestAPI, Tooltip, useEffect, useState, useStateFromStores } from "@webpack/common";
|
||||
import { ChannelStore, Constants, Forms, MessageStore, RestAPI, Tooltip, useEffect, useState, useStateFromStores } from "@webpack/common";
|
||||
import type { ComponentType, HTMLAttributes } from "react";
|
||||
|
||||
declare enum SpinnerTypes {
|
||||
|
@ -38,52 +40,124 @@ const { Spinner } = proxyLazy(() => Forms as any as {
|
|||
SpinnerTypes: typeof SpinnerTypes;
|
||||
});
|
||||
|
||||
const MessageDisplayCompact = getUserSettingLazy("textAndImages", "messageDisplayCompact")!;
|
||||
|
||||
const ChannelMessage = findComponentByCodeLazy("isFirstMessageInForumPost", "trackAnnouncementViews") as ComponentType<any>;
|
||||
|
||||
const settings = definePluginSettings({
|
||||
onLink: {
|
||||
description: "Show tooltip when hovering over message links",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
restartNeeded: true,
|
||||
},
|
||||
onReply: {
|
||||
description: "Show tooltip when hovering over message replies",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
restartNeeded: true,
|
||||
},
|
||||
onForward: {
|
||||
description: "Show tooltip when hovering over forwarded messages",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
restartNeeded: true,
|
||||
},
|
||||
display: {
|
||||
description: "Display style",
|
||||
type: OptionType.SELECT,
|
||||
options: [
|
||||
{
|
||||
label: "Same as message",
|
||||
value: "auto",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "Compact",
|
||||
value: "compact"
|
||||
},
|
||||
{
|
||||
label: "Cozy",
|
||||
value: "cozy"
|
||||
},
|
||||
]
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "MessageLinkTooltip",
|
||||
description: "Like MessageLinkEmbed but without taking space",
|
||||
authors: [Devs.Kyuuhachi],
|
||||
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: ',className:"channelMention",children:[',
|
||||
replacement: {
|
||||
match: /(?<=\.jsxs\)\()(\i\.\i)(?=,\{role:"link")/,
|
||||
replace: "$self.wrapComponent(arguments[0], $1)"
|
||||
}
|
||||
}
|
||||
match: /(?<=\.jsxs\)\()(\i\.\i),\{(?=role:"link")/,
|
||||
replace: "$self.MentionTooltip,{Component:$1,vcProps:arguments[0],"
|
||||
},
|
||||
predicate: () => settings.store.onLink,
|
||||
},
|
||||
{
|
||||
find: "Messages.REPLY_QUOTE_MESSAGE_NOT_LOADED",
|
||||
replacement: {
|
||||
// Should match two places
|
||||
match: /(\i\.Clickable),\{/g,
|
||||
replace: "$self.ReplyTooltip,{Component:$1,vcProps:arguments[0],"
|
||||
},
|
||||
predicate: () => settings.store.onReply,
|
||||
},
|
||||
{
|
||||
find: "Messages.MESSAGE_FORWARDED}",
|
||||
replacement: {
|
||||
match: /(\i\.Clickable),\{/,
|
||||
replace: "$self.ForwardTooltip,{Component:$1,vcProps:arguments[0],"
|
||||
},
|
||||
predicate: () => settings.store.onForward,
|
||||
},
|
||||
],
|
||||
|
||||
wrapComponent({ messageId, channelId }, Component: ComponentType) {
|
||||
return props => {
|
||||
if (messageId === undefined) return <Component {...props} />;
|
||||
return <Tooltip
|
||||
tooltipClassName="c98-message-link-tooltip"
|
||||
text={
|
||||
<ErrorBoundary>
|
||||
<MessagePreview
|
||||
channelId={channelId}
|
||||
messageId={messageId}
|
||||
/>
|
||||
</ErrorBoundary>
|
||||
}
|
||||
>
|
||||
{({ onMouseEnter, onMouseLeave }) =>
|
||||
<Component
|
||||
{...props}
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
/>
|
||||
}
|
||||
</Tooltip>;
|
||||
};
|
||||
}
|
||||
MentionTooltip({ Component, vcProps, ...props }) {
|
||||
return withTooltip(Component, props, vcProps.messageId, vcProps.channelId);
|
||||
},
|
||||
|
||||
ReplyTooltip({ Component, vcProps, ...props }) {
|
||||
const mess = vcProps.baseMessage.messageReference;
|
||||
return withTooltip(Component, props, mess?.message_id, mess?.channel_id);
|
||||
},
|
||||
|
||||
ForwardTooltip({ Component, vcProps, ...props }) {
|
||||
const mess = vcProps.message.messageReference;
|
||||
return withTooltip(Component, props, mess?.message_id, mess?.channel_id);
|
||||
},
|
||||
});
|
||||
|
||||
function withTooltip(Component, props, messageId, channelId) {
|
||||
if (!messageId) return <Component {...props} />;
|
||||
return <Tooltip
|
||||
tooltipClassName="c98-message-link-tooltip"
|
||||
text={
|
||||
<ErrorBoundary>
|
||||
<MessagePreview
|
||||
channelId={channelId}
|
||||
messageId={messageId}
|
||||
/>
|
||||
</ErrorBoundary>
|
||||
}
|
||||
children={({ onMouseEnter, onMouseLeave }) =>
|
||||
<Component {...props} onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} />}
|
||||
/>;
|
||||
}
|
||||
|
||||
function MessagePreview({ channelId, messageId }) {
|
||||
const channel = ChannelStore.getChannel(channelId);
|
||||
const message = useMessage(channelId, messageId);
|
||||
const rawCompact = MessageDisplayCompact.useSetting();
|
||||
|
||||
const compact = settings.store.display === "compact" ? true : settings.store.display === "cozy" ? false : rawCompact;
|
||||
|
||||
// TODO handle load failure
|
||||
if (!message) {
|
||||
return <Spinner type={Spinner.Type.PULSING_ELLIPSIS} />;
|
||||
|
@ -94,6 +168,7 @@ function MessagePreview({ channelId, messageId }) {
|
|||
message={message}
|
||||
channel={channel}
|
||||
subscribeToComponentDispatch={false}
|
||||
compact={compact}
|
||||
/>;
|
||||
}
|
||||
|
||||
|
@ -107,7 +182,7 @@ function useMessage(channelId, messageId) {
|
|||
if (message == null)
|
||||
(async () => {
|
||||
const res = await RestAPI.get({
|
||||
url: `/channels/${channelId}/messages`,
|
||||
url: Constants.Endpoints.MESSAGES(channelId),
|
||||
query: {
|
||||
limit: 1,
|
||||
around: messageId,
|
||||
|
|
34
src/equicordplugins/moreThemes/index.ts
Normal file
34
src/equicordplugins/moreThemes/index.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "MoreThemes",
|
||||
description: "Enables Darker and Midnight themes",
|
||||
authors: [Devs.Kyuuhachi],
|
||||
|
||||
patches: [
|
||||
{
|
||||
// matches twice: the settings menu and the settings context menu
|
||||
find: '("appearance_settings")',
|
||||
replacement: {
|
||||
match: /\("appearance_settings"\)/,
|
||||
replace: "$&||true"
|
||||
},
|
||||
all: true,
|
||||
},
|
||||
{
|
||||
// make it actually save the setting instead of falling back to dark
|
||||
find: 'getCurrentConfig({location:"ThemeStore"}).enabled',
|
||||
replacement: {
|
||||
match: /getCurrentConfig\(\{location:"ThemeStore"\}\)\.enabled/,
|
||||
replace: "$&&&false"
|
||||
},
|
||||
}
|
||||
],
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue