mirror of
https://github.com/Equicord/Equicord.git
synced 2025-02-20 15:18:50 -05:00
Merge remote-tracking branch 'upstream/dev'
This commit is contained in:
commit
691b05a38d
12 changed files with 168 additions and 91 deletions
|
@ -169,5 +169,3 @@ Regardless, if your account is essential to you and getting disabled would be a
|
|||
Additionally, make sure not to post screenshots with Equicord in a server where you might get banned for it
|
||||
|
||||
</details>
|
||||
|
||||
Plugins may take time to be added as I am not on all of the time because of school and stuff.
|
||||
|
|
|
@ -14,7 +14,7 @@ import { Message } from "discord-types/general";
|
|||
* @param messageId The message id
|
||||
* @param fields The fields of the message to change. Leave empty if you just want to re-render
|
||||
*/
|
||||
export function updateMessage(channelId: string, messageId: string, fields?: Partial<Message>) {
|
||||
export function updateMessage(channelId: string, messageId: string, fields?: Partial<Message & Record<string, any>>) {
|
||||
const channelMessageCache = MessageCache.getOrCreate(channelId);
|
||||
if (!channelMessageCache.has(messageId)) return;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ function ReloadRequiredCard({ required }: { required: boolean; }) {
|
|||
<Forms.FormText className={cl("dep-text")}>
|
||||
Restart now to apply new plugins and their settings
|
||||
</Forms.FormText>
|
||||
<Button color={Button.Colors.YELLOW} onClick={() => location.reload()}>
|
||||
<Button onClick={() => location.reload()}>
|
||||
Restart
|
||||
</Button>
|
||||
</>
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
|
||||
.vc-plugins-restart-card button {
|
||||
margin-top: 0.5em;
|
||||
background: var(--info-warning-foreground) !important;
|
||||
}
|
||||
|
||||
.vc-plugins-info-button svg:not(:hover, :focus) {
|
||||
|
|
|
@ -18,18 +18,19 @@
|
|||
|
||||
import "./fixBadgeOverflow.css";
|
||||
|
||||
import { BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
||||
import { _getBadges, BadgePosition, BadgeUserArgs, ProfileBadge } from "@api/Badges";
|
||||
import DonateButton from "@components/DonateButton";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Flex } from "@components/Flex";
|
||||
import { Heart } from "@components/Heart";
|
||||
import { openContributorModal } from "@components/PluginSettings/ContributorModal";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { isEquicordPluginDev, isPluginDev } from "@utils/misc";
|
||||
import { closeModal, Modals, openModal } from "@utils/modal";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Forms, Toasts } from "@webpack/common";
|
||||
import { Forms, Toasts, UserStore } from "@webpack/common";
|
||||
|
||||
const CONTRIBUTOR_BADGE = "https://vencord.dev/assets/favicon.png";
|
||||
const EQUICORD_CONTRIBUTOR_BADGE = "https://i.imgur.com/rJDRtUB.png";
|
||||
|
@ -109,9 +110,61 @@ export default definePlugin({
|
|||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, arguments[0]) }),$&"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
/* new profiles */
|
||||
{
|
||||
find: ".PANEL]:14",
|
||||
replacement: {
|
||||
match: /(?<=\i=\(0,\i\.default\)\(\i\);)return 0===\i.length/,
|
||||
replace: "$& && $self.getBadges(arguments[0]?.displayProfile).length===0"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: ".description,delay:",
|
||||
group: true,
|
||||
replacement: [
|
||||
{
|
||||
match: /...(\i)\}=\(0,\i\.useUserProfileAnalyticsContext\)\(\);/,
|
||||
replace: "$& const VencordProps=$self.getProps($1); arguments[0].badges.unshift(...$self.getBadges($1));"
|
||||
},
|
||||
{
|
||||
// alt: "", aria-hidden: false, src: originalSrc
|
||||
match: /alt:" ","aria-hidden":!0,src:(?=.{0,20}(\i)\.icon)/,
|
||||
// ...badge.props, ..., src: badge.image ?? ...
|
||||
replace: "...$1.props,$& $1.image??"
|
||||
},
|
||||
{
|
||||
match: /(?<=text:(\i)\.description,.{0,50})children:/,
|
||||
replace: "children:$1.component ? $self.renderBadgeComponent({ ...VencordProps, ...$1 }) :"
|
||||
},
|
||||
// conditionally override their onClick with badge.onClick if it exists
|
||||
{
|
||||
match: /href:(\i)\.link/,
|
||||
replace: "...($1.onClick && { onClick: vcE => $1.onClick(vcE, VencordProps) }),$&"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
getProps(props: Record<string, any>) {
|
||||
try {
|
||||
return { ...props, user: UserStore.getUser(props.userId) };
|
||||
} catch {
|
||||
return props;
|
||||
}
|
||||
},
|
||||
|
||||
getBadges(props: { userId: string; guildId: string; }) {
|
||||
try {
|
||||
const { guildId, userId } = props;
|
||||
return _getBadges({ guildId, user: UserStore.getUser(userId) });
|
||||
} catch (e) {
|
||||
new Logger("BadgeAPI#hasBadges").error(e);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
|
||||
toolboxActions: {
|
||||
async "Refetch Badges"() {
|
||||
await loadAllBadges(true);
|
||||
|
|
|
@ -68,6 +68,7 @@ export interface TrackData {
|
|||
const enum AssetImageType {
|
||||
Album = "Album",
|
||||
Artist = "Artist",
|
||||
Disabled = "Disabled"
|
||||
}
|
||||
|
||||
const applicationId = "1239490006054207550";
|
||||
|
@ -126,7 +127,8 @@ const settings = definePluginSettings({
|
|||
description: "Activity assets large image type",
|
||||
options: [
|
||||
{ label: "Album artwork", value: AssetImageType.Album, default: true },
|
||||
{ label: "Artist artwork", value: AssetImageType.Artist }
|
||||
{ label: "Artist artwork", value: AssetImageType.Artist },
|
||||
{ label: "Disabled", value: AssetImageType.Disabled }
|
||||
],
|
||||
},
|
||||
largeTextString: {
|
||||
|
@ -139,7 +141,8 @@ const settings = definePluginSettings({
|
|||
description: "Activity assets small image type",
|
||||
options: [
|
||||
{ label: "Album artwork", value: AssetImageType.Album },
|
||||
{ label: "Artist artwork", value: AssetImageType.Artist, default: true }
|
||||
{ label: "Artist artwork", value: AssetImageType.Artist, default: true },
|
||||
{ label: "Disabled", value: AssetImageType.Disabled }
|
||||
],
|
||||
},
|
||||
smallTextString: {
|
||||
|
@ -207,12 +210,17 @@ export default definePlugin({
|
|||
getImageAsset(settings.store.smallImageType, trackData)
|
||||
]);
|
||||
|
||||
const assets: ActivityAssets = {
|
||||
large_image: largeImageAsset,
|
||||
large_text: customFormat(settings.store.largeTextString, trackData),
|
||||
small_image: smallImageAsset,
|
||||
small_text: customFormat(settings.store.smallTextString, trackData),
|
||||
};
|
||||
const assets: ActivityAssets = {};
|
||||
|
||||
if (settings.store.largeImageType !== AssetImageType.Disabled) {
|
||||
assets.large_image = largeImageAsset;
|
||||
assets.large_text = customFormat(settings.store.largeTextString, trackData);
|
||||
}
|
||||
|
||||
if (settings.store.smallImageType !== AssetImageType.Disabled) {
|
||||
assets.small_image = smallImageAsset;
|
||||
assets.small_text = customFormat(settings.store.smallTextString, trackData);
|
||||
}
|
||||
|
||||
const buttons: ActivityButton[] = [];
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
find: ".ADD_ROLE_A11Y_LABEL",
|
||||
all: true,
|
||||
predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles,
|
||||
noWarn: true,
|
||||
replacement: {
|
||||
|
@ -57,6 +58,7 @@ export default definePlugin({
|
|||
},
|
||||
{
|
||||
find: ".roleVerifiedIcon",
|
||||
all: true,
|
||||
predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles,
|
||||
noWarn: true,
|
||||
replacement: {
|
||||
|
|
|
@ -178,7 +178,7 @@ const settings = definePluginSettings({
|
|||
},
|
||||
startTime: {
|
||||
type: OptionType.NUMBER,
|
||||
description: "Start timestamp in milisecond (only for custom timestamp mode)",
|
||||
description: "Start timestamp in milliseconds (only for custom timestamp mode)",
|
||||
onChange: onChange,
|
||||
disabled: isTimestampDisabled,
|
||||
isValid: (value: number) => {
|
||||
|
@ -188,7 +188,7 @@ const settings = definePluginSettings({
|
|||
},
|
||||
endTime: {
|
||||
type: OptionType.NUMBER,
|
||||
description: "End timestamp in milisecond (only for custom timestamp mode)",
|
||||
description: "End timestamp in milliseconds (only for custom timestamp mode)",
|
||||
onChange: onChange,
|
||||
disabled: isTimestampDisabled,
|
||||
isValid: (value: number) => {
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
import "./messageLogger.css";
|
||||
|
||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { updateMessage } from "@api/MessageUpdater";
|
||||
import { Settings } from "@api/Settings";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
|
@ -26,11 +27,17 @@ import { Devs } from "@utils/constants";
|
|||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ChannelStore, FluxDispatcher, i18n, Menu, Parser, Timestamp, UserStore } from "@webpack/common";
|
||||
import { ChannelStore, FluxDispatcher, i18n, Menu, MessageStore, Parser, Timestamp, UserStore, useStateFromStores } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
import overlayStyle from "./deleteStyleOverlay.css?managed";
|
||||
import textStyle from "./deleteStyleText.css?managed";
|
||||
|
||||
interface MLMessage extends Message {
|
||||
deleted?: boolean;
|
||||
editHistory?: { timestamp: Date; content: string; }[];
|
||||
}
|
||||
|
||||
const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
|
||||
|
||||
function addDeleteStyle() {
|
||||
|
@ -89,35 +96,77 @@ const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) =
|
|||
));
|
||||
};
|
||||
|
||||
const patchChannelContextMenu: NavContextMenuPatchCallback = (children, { channel }) => {
|
||||
const messages = MessageStore.getMessages(channel?.id) as MLMessage[];
|
||||
if (!messages?.some(msg => msg.deleted || msg.editHistory?.length)) return;
|
||||
|
||||
const group = findGroupChildrenByChildId("mark-channel-read", children) ?? children;
|
||||
group.push(
|
||||
<Menu.MenuItem
|
||||
id="vc-ml-clear-channel"
|
||||
label="Clear Message Log"
|
||||
color="danger"
|
||||
action={() => {
|
||||
messages.forEach(msg => {
|
||||
if (msg.deleted)
|
||||
FluxDispatcher.dispatch({
|
||||
type: "MESSAGE_DELETE",
|
||||
channelId: channel.id,
|
||||
id: msg.id,
|
||||
mlDeleted: true
|
||||
});
|
||||
else
|
||||
updateMessage(channel.id, msg.id, {
|
||||
editHistory: []
|
||||
});
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default definePlugin({
|
||||
name: "MessageLogger",
|
||||
description: "Temporarily logs deleted and edited messages.",
|
||||
authors: [Devs.rushii, Devs.Ven, Devs.AutumnVN],
|
||||
authors: [Devs.rushii, Devs.Ven, Devs.AutumnVN, Devs.Nickyux],
|
||||
dependencies: ["MessageUpdaterAPI"],
|
||||
|
||||
contextMenus: {
|
||||
"message": patchMessageContextMenu
|
||||
"message": patchMessageContextMenu,
|
||||
"channel-context": patchChannelContextMenu,
|
||||
"user-context": patchChannelContextMenu,
|
||||
"gdm-context": patchChannelContextMenu
|
||||
},
|
||||
|
||||
start() {
|
||||
addDeleteStyle();
|
||||
},
|
||||
|
||||
renderEdit(edit: { timestamp: any, content: string; }) {
|
||||
return (
|
||||
<ErrorBoundary noop>
|
||||
<div className="messagelogger-edited">
|
||||
{Parser.parse(edit.content)}
|
||||
<Timestamp
|
||||
timestamp={edit.timestamp}
|
||||
isEdited={true}
|
||||
isInline={false}
|
||||
>
|
||||
<span className={styles.edited}>{" "}({i18n.Messages.MESSAGE_EDITED})</span>
|
||||
</Timestamp>
|
||||
</div>
|
||||
</ErrorBoundary>
|
||||
renderEdits: ErrorBoundary.wrap(({ message: { id: messageId, channel_id: channelId } }: { message: Message; }) => {
|
||||
const message = useStateFromStores(
|
||||
[MessageStore],
|
||||
() => MessageStore.getMessage(channelId, messageId) as MLMessage,
|
||||
null,
|
||||
(oldMsg, newMsg) => oldMsg?.editHistory === newMsg?.editHistory
|
||||
);
|
||||
},
|
||||
|
||||
return (
|
||||
<>
|
||||
{message.editHistory?.map(edit => (
|
||||
<div className="messagelogger-edited">
|
||||
{Parser.parse(edit.content)}
|
||||
<Timestamp
|
||||
timestamp={edit.timestamp}
|
||||
isEdited={true}
|
||||
isInline={false}
|
||||
>
|
||||
<span className={styles.edited}>{" "}({i18n.Messages.MESSAGE_EDITED})</span>
|
||||
</Timestamp>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}, { noop: true }),
|
||||
|
||||
makeEdit(newMessage: any, oldMessage: any): any {
|
||||
return {
|
||||
|
@ -222,11 +271,9 @@ export default definePlugin({
|
|||
(message.channel_id === "1026515880080842772" && message.author?.id === "1017176847865352332");
|
||||
},
|
||||
|
||||
// Based on canary 63b8f1b4f2025213c5cf62f0966625bee3d53136
|
||||
patches: [
|
||||
{
|
||||
// MessageStore
|
||||
// Module 171447
|
||||
find: '"MessageStore"',
|
||||
replacement: [
|
||||
{
|
||||
|
@ -271,7 +318,6 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
// Message domain model
|
||||
// Module 451
|
||||
find: "}addReaction(",
|
||||
replacement: [
|
||||
{
|
||||
|
@ -285,14 +331,8 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
// Updated message transformer(?)
|
||||
// Module 819525
|
||||
find: "THREAD_STARTER_MESSAGE?null===",
|
||||
replacement: [
|
||||
// {
|
||||
// // DEBUG: Log the params of the target function to the patch below
|
||||
// match: /function N\(e,t\){/,
|
||||
// replace: "function L(e,t){console.log('pre-transform', e, t);"
|
||||
// },
|
||||
{
|
||||
// Pass through editHistory & deleted & original attachments to the "edited message" transformer
|
||||
match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/,
|
||||
|
@ -300,11 +340,6 @@ export default definePlugin({
|
|||
"Object.assign($&,{ deleted:$1.deleted, editHistory:$1.editHistory, attachments:$1.attachments })"
|
||||
},
|
||||
|
||||
// {
|
||||
// // DEBUG: Log the params of the target function to the patch below
|
||||
// match: /function R\(e\){/,
|
||||
// replace: "function R(e){console.log('after-edit-transform', arguments);"
|
||||
// },
|
||||
{
|
||||
// Construct new edited message and add editHistory & deleted (ref above)
|
||||
// Pass in custom data to attachment parser to mark attachments deleted as well
|
||||
|
@ -335,7 +370,6 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
// Attachment renderer
|
||||
// Module 96063
|
||||
find: ".removeMosaicItemHoverButton",
|
||||
group: true,
|
||||
replacement: [
|
||||
|
@ -352,7 +386,6 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
// Base message component renderer
|
||||
// Module 748241
|
||||
find: "Message must not be a thread starter message",
|
||||
replacement: [
|
||||
{
|
||||
|
@ -365,20 +398,18 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
// Message content renderer
|
||||
// Module 43016
|
||||
find: "Messages.MESSAGE_EDITED,\")\"",
|
||||
replacement: [
|
||||
{
|
||||
// Render editHistory in the deepest div for message content
|
||||
match: /(\)\("div",\{id:.+?children:\[)/,
|
||||
replace: "$1 (arguments[0].message.editHistory?.length > 0 ? arguments[0].message.editHistory.map(edit => $self.renderEdit(edit)) : null), "
|
||||
replace: "$1 (!!arguments[0].message.editHistory?.length && $self.renderEdits(arguments[0])),"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
// ReferencedMessageStore
|
||||
// Module 778667
|
||||
find: '"ReferencedMessageStore"',
|
||||
replacement: [
|
||||
{
|
||||
|
@ -394,7 +425,6 @@ export default definePlugin({
|
|||
|
||||
{
|
||||
// Message context base menu
|
||||
// Module 600300
|
||||
find: "useMessageMenu:",
|
||||
replacement: [
|
||||
{
|
||||
|
@ -404,18 +434,5 @@ export default definePlugin({
|
|||
}
|
||||
]
|
||||
}
|
||||
|
||||
// {
|
||||
// // MessageStore caching internals
|
||||
// // Module 819525
|
||||
// find: "e.getOrCreate=function(t)",
|
||||
// replacement: [
|
||||
// // {
|
||||
// // // DEBUG: log getOrCreate return values from MessageStore caching internals
|
||||
// // match: /getOrCreate=function(.+?)return/,
|
||||
// // replace: "getOrCreate=function$1console.log('getOrCreate',n);return"
|
||||
// // }
|
||||
// ]
|
||||
// }
|
||||
]
|
||||
});
|
||||
|
|
|
@ -200,7 +200,7 @@ export default definePlugin({
|
|||
}
|
||||
},
|
||||
{
|
||||
find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP,",
|
||||
find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP_OFFICIAL,",
|
||||
replacement: [
|
||||
// make the tag show the right text
|
||||
{
|
||||
|
|
|
@ -61,11 +61,7 @@ export default definePlugin({
|
|||
replacement: [
|
||||
{
|
||||
match: /(\i)\.premiumType/,
|
||||
replace: "$self.premiumHook($1)||$&"
|
||||
},
|
||||
{
|
||||
match: /(?<=function \i\((\i)\)\{)(?=var.+?,bannerSrc:)/,
|
||||
replace: "$1.bannerSrc=$self.useBannerHook($1);"
|
||||
replace: "$self.patchPremiumType($1)||$&"
|
||||
},
|
||||
{
|
||||
match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/,
|
||||
|
@ -74,17 +70,19 @@ export default definePlugin({
|
|||
]
|
||||
},
|
||||
{
|
||||
find: /overrideBannerSrc:\i,overrideBannerWidth:/,
|
||||
replacement: [
|
||||
{
|
||||
match: /(\i)\.premiumType/,
|
||||
replace: "$self.premiumHook($1)||$&"
|
||||
},
|
||||
{
|
||||
match: /function \i\((\i)\)\{/,
|
||||
replace: "$&$1.overrideBannerSrc=$self.useBannerHook($1);"
|
||||
}
|
||||
]
|
||||
find: "=!1,canUsePremiumCustomization:",
|
||||
replacement: {
|
||||
match: /(\i)\.premiumType/,
|
||||
replace: "$self.patchPremiumType($1)||$&"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "BannerLoadingStatus:function",
|
||||
replacement: {
|
||||
match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/,
|
||||
replace: "$self.patchBannerUrl(arguments[0])||$&"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
find: /profileType:\i,pendingBanner:/,
|
||||
|
@ -105,7 +103,7 @@ export default definePlugin({
|
|||
replacement: [
|
||||
{
|
||||
match: /(?<=function\((\i),\i\)\{)(?=let.{20,40},style:)/,
|
||||
replace: "$1.style=$self.voiceBackgroundHook($1);"
|
||||
replace: "$1.style=$self.getVoiceBackgroundStyles($1);"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -119,7 +117,7 @@ export default definePlugin({
|
|||
);
|
||||
},
|
||||
|
||||
voiceBackgroundHook({ className, participantUserId }: any) {
|
||||
getVoiceBackgroundStyles({ className, participantUserId }: any) {
|
||||
if (className.includes("tile_")) {
|
||||
if (this.userHasBackground(participantUserId)) {
|
||||
return {
|
||||
|
@ -132,12 +130,12 @@ export default definePlugin({
|
|||
}
|
||||
},
|
||||
|
||||
useBannerHook({ displayProfile, user }: any) {
|
||||
patchBannerUrl({ displayProfile }: any) {
|
||||
if (displayProfile?.banner && settings.store.nitroFirst) return;
|
||||
if (this.userHasBackground(user.id)) return this.getImageUrl(user.id);
|
||||
if (this.userHasBackground(displayProfile?.userId)) return this.getImageUrl(displayProfile?.userId);
|
||||
},
|
||||
|
||||
premiumHook({ userId }: any) {
|
||||
patchPremiumType({ userId }: any) {
|
||||
if (this.userHasBackground(userId)) return 2;
|
||||
},
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ export default definePlugin({
|
|||
}
|
||||
})),
|
||||
// Banners
|
||||
...[".NITRO_BANNER,", /overrideBannerSrc:\i,overrideBannerWidth:/, /profileType:\i,pendingBanner:/].map(find => ({
|
||||
...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({
|
||||
find,
|
||||
replacement: {
|
||||
// style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl,
|
||||
|
|
Loading…
Add table
Reference in a new issue