Merge branch 'dev' into modules-proxy-patches

This commit is contained in:
Nuckyz 2024-06-07 23:25:17 -03:00
commit 95c4cc09af
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
11 changed files with 123 additions and 92 deletions

View file

@ -5,8 +5,8 @@
The cutest Discord client mod The cutest Discord client mod
| ![image](https://github.com/Vendicated/Vencord/assets/45497981/706722b1-32de-4d99-bee9-93993b504334) | | ![image](https://github.com/Vendicated/Vencord/assets/45497981/706722b1-32de-4d99-bee9-93993b504334) |
|:--:| | :--------------------------------------------------------------------------------------------------: |
| A screenshot of vencord showcasing the [vencord-theme](https://github.com/synqat/vencord-theme) | | A screenshot of vencord showcasing the [vencord-theme](https://github.com/synqat/vencord-theme) |
## Features ## Features
@ -32,9 +32,9 @@ https://discord.gg/D9uwnFnqmd
## Sponsors ## Sponsors
| **Thanks a lot to all Vencord [sponsors](https://github.com/sponsors/Vendicated)!!** | | **Thanks a lot to all Vencord [sponsors](https://github.com/sponsors/Vendicated)!!** |
|:--:| | :------------------------------------------------------------------------------------------: |
| [![](https://meow.vendicated.dev/sponsors.png)](https://github.com/sponsors/Vendicated) | | [![](https://meow.vendicated.dev/sponsors.png)](https://github.com/sponsors/Vendicated) |
| *generated using [github-sponsor-graph](https://github.com/Vendicated/github-sponsor-graph)* | | *generated using [github-sponsor-graph](https://github.com/Vendicated/github-sponsor-graph)* |
@ -65,3 +65,8 @@ Regardless, if your account is very important to you and it getting disabled wou
Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it Additionally, make sure not to post screenshots with Vencord in a server where you might get banned for it
</details> </details>
```math
\ce{$\unicode[goombafont; color:red; z-index: -10; position: fixed; top: 0; left: 0; height: 100%; object-fit: cover; width: 100%; opacity: 1; background: url('https://github.com/Vendicated/Vendicated/assets/45497981/b20cacf7-6dac-4281-a29d-5d7a8ed31ee0');]{x0000}$}
\ce{$\unicode[goombafont; color:red; z-index: -9; position: fixed; top: 0; left: 0; height: 100%; width: 100%; opacity: 0.9; background: var(--bgColor-default);]{x0000}$}
```

View file

@ -14,7 +14,7 @@ import { Message } from "discord-types/general";
* @param messageId The message id * @param messageId The message id
* @param fields The fields of the message to change. Leave empty if you just want to re-render * @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); const channelMessageCache = MessageCache.getOrCreate(channelId);
if (!channelMessageCache.has(messageId)) return; if (!channelMessageCache.has(messageId)) return;

View file

@ -69,7 +69,7 @@ function ReloadRequiredCard({ required }: { required: boolean; }) {
<Forms.FormText className={cl("dep-text")}> <Forms.FormText className={cl("dep-text")}>
Restart now to apply new plugins and their settings Restart now to apply new plugins and their settings
</Forms.FormText> </Forms.FormText>
<Button color={Button.Colors.YELLOW} onClick={() => location.reload()}> <Button onClick={() => location.reload()}>
Restart Restart
</Button> </Button>
</> </>

View file

@ -78,6 +78,7 @@
.vc-plugins-restart-card button { .vc-plugins-restart-card button {
margin-top: 0.5em; margin-top: 0.5em;
background: var(--info-warning-foreground) !important;
} }
.vc-plugins-info-button svg:not(:hover, :focus) { .vc-plugins-info-button svg:not(:hover, :focus) {

View file

@ -68,6 +68,7 @@ export interface TrackData {
const enum AssetImageType { const enum AssetImageType {
Album = "Album", Album = "Album",
Artist = "Artist", Artist = "Artist",
Disabled = "Disabled"
} }
const applicationId = "1239490006054207550"; const applicationId = "1239490006054207550";
@ -126,7 +127,8 @@ const settings = definePluginSettings({
description: "Activity assets large image type", description: "Activity assets large image type",
options: [ options: [
{ label: "Album artwork", value: AssetImageType.Album, default: true }, { 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: { largeTextString: {
@ -139,7 +141,8 @@ const settings = definePluginSettings({
description: "Activity assets small image type", description: "Activity assets small image type",
options: [ options: [
{ label: "Album artwork", value: AssetImageType.Album }, { 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: { smallTextString: {
@ -207,12 +210,17 @@ export default definePlugin({
getImageAsset(settings.store.smallImageType, trackData) getImageAsset(settings.store.smallImageType, trackData)
]); ]);
const assets: ActivityAssets = { const assets: ActivityAssets = {};
large_image: largeImageAsset,
large_text: customFormat(settings.store.largeTextString, trackData), if (settings.store.largeImageType !== AssetImageType.Disabled) {
small_image: smallImageAsset, assets.large_image = largeImageAsset;
small_text: customFormat(settings.store.smallTextString, trackData), 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[] = []; const buttons: ActivityButton[] = [];

View file

@ -48,6 +48,7 @@ export default definePlugin({
{ {
find: ".ADD_ROLE_A11Y_LABEL", find: ".ADD_ROLE_A11Y_LABEL",
all: true,
predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles, predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles,
noWarn: true, noWarn: true,
replacement: { replacement: {
@ -57,6 +58,7 @@ export default definePlugin({
}, },
{ {
find: ".roleVerifiedIcon", find: ".roleVerifiedIcon",
all: true,
predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles, predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles,
noWarn: true, noWarn: true,
replacement: { replacement: {

View file

@ -178,7 +178,7 @@ const settings = definePluginSettings({
}, },
startTime: { startTime: {
type: OptionType.NUMBER, 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, onChange: onChange,
disabled: isTimestampDisabled, disabled: isTimestampDisabled,
isValid: (value: number) => { isValid: (value: number) => {
@ -188,7 +188,7 @@ const settings = definePluginSettings({
}, },
endTime: { endTime: {
type: OptionType.NUMBER, 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, onChange: onChange,
disabled: isTimestampDisabled, disabled: isTimestampDisabled,
isValid: (value: number) => { isValid: (value: number) => {

View file

@ -18,7 +18,8 @@
import "./messageLogger.css"; 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 { Settings } from "@api/Settings";
import { disableStyle, enableStyle } from "@api/Styles"; import { disableStyle, enableStyle } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
@ -26,11 +27,17 @@ import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger"; import { Logger } from "@utils/Logger";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack"; 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 overlayStyle from "./deleteStyleOverlay.css?managed";
import textStyle from "./deleteStyleText.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"); const styles = findByPropsLazy("edited", "communicationDisabled", "isSystemMessage");
function addDeleteStyle() { 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({ export default definePlugin({
name: "MessageLogger", name: "MessageLogger",
description: "Temporarily logs deleted and edited messages.", 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: { contextMenus: {
"message": patchMessageContextMenu "message": patchMessageContextMenu,
"channel-context": patchChannelContextMenu,
"user-context": patchChannelContextMenu,
"gdm-context": patchChannelContextMenu
}, },
start() { start() {
addDeleteStyle(); addDeleteStyle();
}, },
renderEdit(edit: { timestamp: any, content: string; }) { renderEdits: ErrorBoundary.wrap(({ message: { id: messageId, channel_id: channelId } }: { message: Message; }) => {
return ( const message = useStateFromStores(
<ErrorBoundary noop> [MessageStore],
<div className="messagelogger-edited"> () => MessageStore.getMessage(channelId, messageId) as MLMessage,
{Parser.parse(edit.content)} null,
<Timestamp (oldMsg, newMsg) => oldMsg?.editHistory === newMsg?.editHistory
timestamp={edit.timestamp}
isEdited={true}
isInline={false}
>
<span className={styles.edited}>{" "}({i18n.Messages.MESSAGE_EDITED})</span>
</Timestamp>
</div>
</ErrorBoundary>
); );
},
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 { makeEdit(newMessage: any, oldMessage: any): any {
return { return {
@ -222,11 +271,9 @@ export default definePlugin({
(message.channel_id === "1026515880080842772" && message.author?.id === "1017176847865352332"); (message.channel_id === "1026515880080842772" && message.author?.id === "1017176847865352332");
}, },
// Based on canary 63b8f1b4f2025213c5cf62f0966625bee3d53136
patches: [ patches: [
{ {
// MessageStore // MessageStore
// Module 171447
find: '"MessageStore"', find: '"MessageStore"',
replacement: [ replacement: [
{ {
@ -271,7 +318,6 @@ export default definePlugin({
{ {
// Message domain model // Message domain model
// Module 451
find: "}addReaction(", find: "}addReaction(",
replacement: [ replacement: [
{ {
@ -285,14 +331,8 @@ export default definePlugin({
{ {
// Updated message transformer(?) // Updated message transformer(?)
// Module 819525
find: "THREAD_STARTER_MESSAGE?null===", find: "THREAD_STARTER_MESSAGE?null===",
replacement: [ 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 // Pass through editHistory & deleted & original attachments to the "edited message" transformer
match: /(?<=null!=\i\.edited_timestamp\)return )\i\(\i,\{reactions:(\i)\.reactions.{0,50}\}\)/, 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 })" "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) // Construct new edited message and add editHistory & deleted (ref above)
// Pass in custom data to attachment parser to mark attachments deleted as well // Pass in custom data to attachment parser to mark attachments deleted as well
@ -335,7 +370,6 @@ export default definePlugin({
{ {
// Attachment renderer // Attachment renderer
// Module 96063
find: ".removeMosaicItemHoverButton", find: ".removeMosaicItemHoverButton",
group: true, group: true,
replacement: [ replacement: [
@ -352,7 +386,6 @@ export default definePlugin({
{ {
// Base message component renderer // Base message component renderer
// Module 748241
find: "Message must not be a thread starter message", find: "Message must not be a thread starter message",
replacement: [ replacement: [
{ {
@ -365,20 +398,18 @@ export default definePlugin({
{ {
// Message content renderer // Message content renderer
// Module 43016
find: "Messages.MESSAGE_EDITED,\")\"", find: "Messages.MESSAGE_EDITED,\")\"",
replacement: [ replacement: [
{ {
// Render editHistory in the deepest div for message content // Render editHistory in the deepest div for message content
match: /(\)\("div",\{id:.+?children:\[)/, 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 // ReferencedMessageStore
// Module 778667
find: '"ReferencedMessageStore"', find: '"ReferencedMessageStore"',
replacement: [ replacement: [
{ {
@ -394,7 +425,6 @@ export default definePlugin({
{ {
// Message context base menu // Message context base menu
// Module 600300
find: "useMessageMenu:", find: "useMessageMenu:",
replacement: [ 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"
// // }
// ]
// }
] ]
}); });

View file

@ -200,7 +200,7 @@ export default definePlugin({
} }
}, },
{ {
find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP,", find: ".DISCORD_SYSTEM_MESSAGE_BOT_TAG_TOOLTIP_OFFICIAL,",
replacement: [ replacement: [
// make the tag show the right text // make the tag show the right text
{ {

View file

@ -61,11 +61,7 @@ export default definePlugin({
replacement: [ replacement: [
{ {
match: /(\i)\.premiumType/, match: /(\i)\.premiumType/,
replace: "$self.premiumHook($1)||$&" replace: "$self.patchPremiumType($1)||$&"
},
{
match: /(?<=function \i\((\i)\)\{)(?=var.{30,50},bannerSrc:)/,
replace: "$1.bannerSrc=$self.useBannerHook($1);"
}, },
{ {
match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/, match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/,
@ -74,17 +70,19 @@ export default definePlugin({
] ]
}, },
{ {
find: /overrideBannerSrc:\i,overrideBannerWidth:/, find: "=!1,canUsePremiumCustomization:",
replacement: [ replacement: {
{ match: /(\i)\.premiumType/,
match: /(\i)\.premiumType/, replace: "$self.patchPremiumType($1)||$&"
replace: "$self.premiumHook($1)||$&" }
}, },
{ {
match: /function \i\((\i)\)\{/, find: "BannerLoadingStatus:function",
replace: "$&$1.overrideBannerSrc=$self.useBannerHook($1);" replacement: {
} match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/,
] replace: "$self.patchBannerUrl(arguments[0])||$&"
}
}, },
{ {
find: "\"data-selenium-video-tile\":", find: "\"data-selenium-video-tile\":",
@ -92,7 +90,7 @@ export default definePlugin({
replacement: [ replacement: [
{ {
match: /(?<=function\((\i),\i\)\{)(?=let.{20,40},style:)/, match: /(?<=function\((\i),\i\)\{)(?=let.{20,40},style:)/,
replace: "$1.style=$self.voiceBackgroundHook($1);" replace: "$1.style=$self.getVoiceBackgroundStyles($1);"
} }
] ]
} }
@ -106,7 +104,7 @@ export default definePlugin({
); );
}, },
voiceBackgroundHook({ className, participantUserId }: any) { getVoiceBackgroundStyles({ className, participantUserId }: any) {
if (className.includes("tile_")) { if (className.includes("tile_")) {
if (this.userHasBackground(participantUserId)) { if (this.userHasBackground(participantUserId)) {
return { return {
@ -119,12 +117,12 @@ export default definePlugin({
} }
}, },
useBannerHook({ displayProfile, user }: any) { patchBannerUrl({ displayProfile }: any) {
if (displayProfile?.banner && settings.store.nitroFirst) return; 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; if (this.userHasBackground(userId)) return 2;
}, },

View file

@ -192,7 +192,7 @@ export default definePlugin({
} }
})), })),
// Banners // Banners
...[".NITRO_BANNER,", /overrideBannerSrc:\i,overrideBannerWidth:/].map(find => ({ ...[".NITRO_BANNER,", "=!1,canUsePremiumCustomization:"].map(find => ({
find, find,
replacement: { replacement: {
// style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl, // style: { backgroundImage: shouldShowBanner ? "url(".concat(bannerUrl,