Skip to content

Commit

Permalink
second batch of fixes (#2596)
Browse files Browse the repository at this point in the history
Co-authored-by: programminglaboratorys <[email protected]>
Co-authored-by: Haruka <[email protected]>
Co-authored-by: Amia <[email protected]>
Co-authored-by: AutumnVN <[email protected]>
Co-authored-by: Nuckyz <[email protected]>
  • Loading branch information
6 people authored Jun 19, 2024
1 parent d6f1209 commit d19b0ae
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 63 deletions.
4 changes: 2 additions & 2 deletions src/plugins/_api/chatButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default definePlugin({
patches: [{
find: '"sticker")',
replacement: {
match: /!\i\.isMobile(?=.+?(\i)\.push\(.{0,50}"gift")/,
replace: "$& &&(Vencord.Api.ChatButtons._injectButtons($1,arguments[0]),true)"
match: /return\(!\i\.\i&&(?=\(\i\.isDM.+?(\i)\.push\(.{0,50}"gift")/,
replace: "$&(Vencord.Api.ChatButtons._injectButtons($1,arguments[0]),true)&&"
}
}]
});
2 changes: 1 addition & 1 deletion src/plugins/_api/messageEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default definePlugin({
replacement: {
// props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply);
// Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid)
match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptionsForReply\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/,
match: /(type:this\.props\.chatInputType.+?\.then\()(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.\i\(\i\);)(?<=\)\(({.+?})\)\.then.+?)/,
// props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true };
replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" +
`${rest1}async ${rest2}` +
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/banger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default definePlugin({
{
find: "BAN_CONFIRM_TITLE.",
replacement: {
match: /src:\i\("\d+"\)/g,
match: /src:\i\(\d+\)/g,
replace: "src: Vencord.Settings.plugins.BANger.source"
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/betterFolders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findStoreLazy } from "@webpack";
import { findByPropsLazy, findLazy, findStoreLazy } from "@webpack";
import { FluxDispatcher, i18n, useMemo } from "@webpack/common";

import FolderSideBar from "./FolderSideBar";
Expand All @@ -30,7 +30,7 @@ enum FolderIconDisplay {
MoreThanOneFolderExpanded
}

const { GuildsTree } = findByPropsLazy("GuildsTree");
const GuildsTree = findLazy(m => m.prototype?.moveNextTo);
const SortedGuildStore = findStoreLazy("SortedGuildStore");
export const ExpandedGuildFolderStore = findStoreLazy("ExpandedGuildFolderStore");
const FolderUtils = findByPropsLazy("move", "toggleGuildFolderExpand");
Expand Down Expand Up @@ -117,7 +117,7 @@ export default definePlugin({
},
// If we are rendering the Better Folders sidebar, we filter out guilds that are not in folders and unexpanded folders
{
match: /\[(\i)\]=(\(0,\i\.useStateFromStoresArray\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
match: /\[(\i)\]=(\(0,\i\.\i\).{0,40}getGuildsTree\(\).+?}\))(?=,)/,
replace: (_, originalTreeVar, rest) => `[betterFoldersOriginalTree]=${rest},${originalTreeVar}=$self.getGuildTree(!!arguments[0].isBetterFolders,betterFoldersOriginalTree,arguments[0].betterFoldersExpandedIds)`
},
// If we are rendering the Better Folders sidebar, we filter out everything but the servers and folders from the GuildsBar Guild List children
Expand All @@ -139,12 +139,12 @@ export default definePlugin({
},
{
// This is the parent folder component
find: ".MAX_GUILD_FOLDER_NAME_LENGTH,",
find: ".toggleGuildFolderExpand(",
predicate: () => settings.store.sidebar && settings.store.showFolderIcon !== FolderIconDisplay.Always,
replacement: [
{
// Modify the expanded state to instead return the list of expanded folders
match: /(useStateFromStores\).{0,20}=>)(\i\.\i)\.isFolderExpanded\(\i\)/,
match: /(\i\).{0,20}=>)(\i\.\i)\.isFolderExpanded\(\i\)/,
replace: (_, rest, ExpandedGuildFolderStore) => `${rest}${ExpandedGuildFolderStore}.getExpandedFolders()`,
},
{
Expand Down Expand Up @@ -196,7 +196,7 @@ export default definePlugin({
]
},
{
find: "APPLICATION_LIBRARY,render",
find: "APPLICATION_LIBRARY,render:",
predicate: () => settings.store.sidebar,
replacement: {
// Render the Better Folders sidebar
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/betterGifPicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default definePlugin({
authors: [Devs.Samwich],
patches: [
{
find: ".GIFPickerResultTypes.SEARCH",
find: '"state",{resultType:',
replacement: [{
match: /(?<="state",{resultType:)null/,
replace: '"Favorites"'
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/ctrlEnterSend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export default definePlugin({
}),
patches: [
{
find: "KeyboardKeys.ENTER&&(!",
find: ".ENTER&&(!",
replacement: {
match: /(?<=(\i)\.which===\i\.KeyboardKeys.ENTER&&).{0,100}(\(0,\i\.hasOpenPlainTextCodeBlock\)\(\i\)).{0,100}(?=&&\(\i\.preventDefault)/,
match: /(?<=(\i)\.which===\i\.\i.ENTER&&).{0,100}(\(0,\i\.\i\)\(\i\)).{0,100}(?=&&\(\i\.preventDefault)/,
replace: "$self.shouldSubmit($1, $2)"
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/plugins/decor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "./ui/styles.css";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { UserStore } from "@webpack/common";

import { CDN_URL, RAW_SKU_ID, SKU_ID } from "./lib/constants";
Expand All @@ -20,7 +19,6 @@ import { settings } from "./settings";
import { setDecorationGridDecoration, setDecorationGridItem } from "./ui/components";
import DecorSection from "./ui/components/DecorSection";

const { isAnimatedAvatarDecoration } = findByPropsLazy("isAnimatedAvatarDecoration");
export interface AvatarDecoration {
asset: string;
skuId: string;
Expand Down Expand Up @@ -61,7 +59,7 @@ export default definePlugin({
},
// Remove NEW label from decor avatar decorations
{
match: /(?<=\.Section\.PREMIUM_PURCHASE&&\i)(?<=avatarDecoration:(\i).+?)/,
match: /(?<=\.\i\.PREMIUM_PURCHASE&&\i)(?<=avatarDecoration:(\i).+?)/,
replace: "||$1.skuId===$self.SKU_ID"
}
]
Expand Down Expand Up @@ -93,7 +91,7 @@ export default definePlugin({
replacement: [
// Use Decor avatar decoration hook
{
match: /(?<=getAvatarDecorationURL\)\({avatarDecoration:)(\i).avatarDecoration(?=,)/,
match: /(?<=\i\)\({avatarDecoration:)(\i).avatarDecoration(?=,)/,
replace: "$self.useUserDecorAvatarDecoration($1)??$&"
}
]
Expand Down Expand Up @@ -133,7 +131,7 @@ export default definePlugin({
if (avatarDecoration?.skuId === SKU_ID) {
const parts = avatarDecoration.asset.split("_");
// Remove a_ prefix if it's animated and animation is disabled
if (isAnimatedAvatarDecoration(avatarDecoration.asset) && !canAnimate) parts.shift();
if (avatarDecoration.asset.startsWith("a_") && !canAnimate) parts.shift();
return `${CDN_URL}/${parts.join("_")}.png`;
} else if (avatarDecoration?.skuId === RAW_SKU_ID) {
return avatarDecoration.asset;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/disableCallIdle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default definePlugin({
{
find: ".Messages.BOT_CALL_IDLE_DISCONNECT",
replacement: {
match: /,?(?=\i\(this,"idleTimeout",new \i\.Timeout\))/,
match: /,?(?=\i\(this,"idleTimeout",new \i\.\i\))/,
replace: ";return;"
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/favEmojiFirst/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default definePlugin({
},

{
find: "MAX_AUTOCOMPLETE_RESULTS+",
find: "numLockedEmojiResults:",
replacement: [
// set maxCount to Infinity so our sortEmojis callback gets the entire list, not just the first 10
// and remove Discord's emojiResult slice, storing the endIndex on the array for us to use later
Expand Down
7 changes: 1 addition & 6 deletions src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@ const pluginsValues = Object.values(Plugins);
const settings = Settings.plugins;

const forceDisabled = new Set([
"MessageLogger",
"ShowHiddenChannels",
"MoreUserTags",
"Decor",
"IgnoreActivities",
"NoBlockedMessages",
"BetterFolders"
"MoreUserTags"
]);
export function isPluginEnabled(p: string) {
return (
Expand Down
14 changes: 8 additions & 6 deletions src/plugins/maskedLinkPaste/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export default definePlugin({
name: "MaskedLinkPaste",
authors: [Devs.TheSun],
description: "Pasting a link while having text selected will paste a hyperlink",
patches: [{
find: ".selection,preventEmojiSurrogates:",
replacement: {
match: /(?<=SlateTransforms.delete.{0,50})(\i)\.insertText\((\i)\)/,
replace: "$self.handlePaste($1, $2, () => $&)"
patches: [
{
find: ".selection,preventEmojiSurrogates:",
replacement: {
match: /(?<=\i.delete.{0,50})(\i)\.insertText\((\i)\)/,
replace: "$self.handlePaste($1, $2, () => $&)"
}
}
}],
],

handlePaste(editor, content: string, originalBehavior: () => void) {
if (content && linkRegex.test(content) && editor.operations?.[0]?.type === "remove_text") {
Expand Down
12 changes: 10 additions & 2 deletions src/plugins/noBlockedMessages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import { Settings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { Logger } from "@utils/Logger";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Message } from "discord-types/general";

const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");

Expand Down Expand Up @@ -59,6 +61,12 @@ export default definePlugin({
restartNeeded: true,
},
},
isBlocked: message =>
RelationshipStore.isBlocked(message.author.id)

isBlocked(message: Message) {
try {
return RelationshipStore.isBlocked(message.author.id);
} catch (e) {
new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e);
}
}
});
2 changes: 1 addition & 1 deletion src/plugins/noDefaultHangStatus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default definePlugin({

patches: [
{
find: "HangStatusTypes.CHILLING)",
find: ".CHILLING)",
replacement: {
match: /{enableHangStatus:(\i),/,
replace: "{_enableHangStatus:$1=false,"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/noMosaic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default definePlugin({

patches: [
{
find: "isGroupableMedia:function()",
find: '=>"IMAGE"===',
replacement: {
match: /=>"IMAGE"===\i\|\|"VIDEO"===\i;/,
replace: "=>false;"
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/openInApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default definePlugin({
{
find: "trackAnnouncementMessageLinkClicked({",
replacement: {
match: /(?<=handleClick:function\(\)\{return (\i)\}.+?)function \1\(.+?\)\{/,
replace: "async $& if(await $self.handleLink(...arguments)) return;"
match: /function (\i\(\i,\i\)\{)(?=.{0,100}trusted:)/,
replace: "async function $1 if(await $self.handleLink(...arguments)) return;"
}
},
// Make Spotify profile activity links open in app on web
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/pauseInvitesForever/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { findLazy } from "@webpack";
import { Constants, GuildStore, i18n, RestAPI } from "@webpack/common";

const { InvitesDisabledExperiment } = findByPropsLazy("InvitesDisabledExperiment");
const InvitesDisabledExperiment = findLazy(m => m.definition?.id === "2022-07_invites_disabled");

function showDisableInvites(guildId: string) {
// Once the experiment is removed, this should keep working
Expand Down Expand Up @@ -56,7 +56,7 @@ export default definePlugin({
replace: "children: $self.renderInvitesLabel({guildId:arguments[0].guildId,setChecked})",
},
{
match: /(\i\.hasDMsDisabled\)\(\i\),\[\i,(\i)\]=\i\.useState\(\i\))/,
match: /(\i\.\i\)\(\i\),\[\i,(\i)\]=\i\.useState\(\i\))/,
replace: "$1,setChecked=$2"
}
]
Expand Down
12 changes: 7 additions & 5 deletions src/plugins/replyTimestamp/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import "./style.css";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { filters, findByPropsLazy, mapMangledModuleLazy } from "@webpack";
import { Timestamp } from "@webpack/common";
import type { Message } from "discord-types/general";
import type { HTMLAttributes } from "react";

const { getMessageTimestampId } = findByPropsLazy("getMessageTimestampId");
const { calendarFormat, dateFormat, isSameDay } = findByPropsLazy("calendarFormat", "dateFormat", "isSameDay", "accessibilityLabelCalendarFormat");
const { calendarFormat, dateFormat, isSameDay } = mapMangledModuleLazy("millisecondsInUnit:", {
calendarFormat: filters.byCode("sameElse"),
dateFormat: filters.byCode('":'),
isSameDay: filters.byCode("Math.abs(+"),
});
const MessageClasses = findByPropsLazy("separator", "latin24CompactTimeStamp");

function Sep(props: HTMLAttributes<HTMLElement>) {
Expand All @@ -42,7 +45,6 @@ function ReplyTimestamp({
const baseTimestamp = baseMessage.timestamp as any;
return (
<Timestamp
id={getMessageTimestampId(referencedMessage.message)}
className="vc-reply-timestamp"
compact={isSameDay(refTimestamp, baseTimestamp)}
timestamp={refTimestamp}
Expand All @@ -65,7 +67,7 @@ export default definePlugin({

patches: [
{
find: "renderSingleLineMessage:function()",
find: ".REPLY_QUOTE_MESSAGE_BLOCKED",
replacement: {
match: /(?<="aria-label":\i,children:\[)(?=\i,\i,\i\])/,
replace: "$self.ReplyTimestamp(arguments[0]),"
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/roleColorEverywhere/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default definePlugin({
{
find: ".reactorDefault",
replacement: {
match: /\.openUserContextMenu\)\((\i),(\i),\i\).{0,250}tag:"strong"/,
match: /,onContextMenu:e=>.{0,15}\((\i),(\i),(\i)\).{0,250}tag:"strong"/,
replace: "$&,style:{color:$self.getColor($2?.id,$1)}"
},
predicate: () => settings.store.reactorsList,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/showMeYourName/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default definePlugin({
authors: [Devs.Rini, Devs.TheKodeToad],
patches: [
{
find: ".useCanSeeRemixBadge)",
find: '?"@":"")',
replacement: {
match: /(?<=onContextMenu:\i,children:).*?\)}/,
replace: "$self.renderUsername(arguments[0])}"
Expand Down
20 changes: 5 additions & 15 deletions src/plugins/usrbg/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ export default definePlugin({
patches: [
{
find: ".NITRO_BANNER,",
replacement: [
{
match: /(\i)\.premiumType/,
replace: "$self.patchPremiumType($1)||$&"
},
{
match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/,
replace: "&&$self.shouldShowBadge(arguments[0])$&"
}
]
replacement: {
match: /\?\(0,\i\.jsx\)\(\i,{type:\i,shown/,
replace: "&&$self.shouldShowBadge(arguments[0])$&"
}
},
{
find: "BannerLoadingStatus:function",
find: ".banner)==null",
replacement: {
match: /(?<=void 0:)\i.getPreviewBanner\(\i,\i,\i\)/,
replace: "$self.patchBannerUrl(arguments[0])||$&"
Expand Down Expand Up @@ -115,10 +109,6 @@ export default definePlugin({
if (this.userHasBackground(displayProfile?.userId)) return this.getImageUrl(displayProfile?.userId);
},

patchPremiumType({ userId }: any) {
if (this.userHasBackground(userId)) return 2;
},

shouldShowBadge({ displayProfile, user }: any) {
return displayProfile?.banner && (!this.userHasBackground(user.id) || settings.store.nitroFirst);
},
Expand Down

0 comments on commit d19b0ae

Please sign in to comment.