diff --git a/src/plugins/_api/badges.tsx b/src/plugins/_api/badges.tsx index 6cbe1feb0..3cfbb4d99 100644 --- a/src/plugins/_api/badges.tsx +++ b/src/plugins/_api/badges.tsx @@ -78,7 +78,7 @@ export default definePlugin({ }, // replace their component with ours if applicable { - match: /(?<=text:(\i)\.description,spacing:12,)children:/, + match: /(?<=text:(\i)\.description,spacing:12,.{0,50})children:/, replace: "children:$1.component ? () => $self.renderBadgeComponent($1) :" }, // conditionally override their onClick with badge.onClick if it exists diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index 07ddc855e..33e7324d2 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -81,8 +81,8 @@ export default definePlugin({ find: "getRelationshipCounts(){", replacement: { predicate: () => Settings.plugins.ImplicitRelationships.sortByAffinity, - match: /\.sortBy\(\i=>\i\.comparator\)/, - replace: "$&.sortBy((row) => $self.sortList(row))" + match: /\}\)\.sortBy\((.+?)\)\.value\(\)/, + replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()" } }, @@ -120,10 +120,10 @@ export default definePlugin({ } ), - sortList(row: any) { + wrapSort(comparator: Function, row: any) { return row.type === 5 ? -UserAffinitiesStore.getUserAffinity(row.user.id)?.affinity ?? 0 - : row.comparator; + : comparator(row); }, async fetchImplicitRelationships() { diff --git a/src/plugins/messageClickActions/index.ts b/src/plugins/messageClickActions/index.ts index f46e34841..61bf79029 100644 --- a/src/plugins/messageClickActions/index.ts +++ b/src/plugins/messageClickActions/index.ts @@ -17,7 +17,7 @@ */ import { addClickListener, removeClickListener } from "@api/MessageEvents"; -import { definePluginSettings, Settings } from "@api/Settings"; +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByProps } from "@webpack"; @@ -84,11 +84,17 @@ export default definePlugin({ const EPHEMERAL = 64; if (msg.hasFlag(EPHEMERAL)) return; + const isShiftPress = event.shiftKey && !settings.store.requireModifier; + const NoReplyMention = Vencord.Plugins.plugins.NoReplyMention as any as typeof import("../noReplyMention").default; + const shouldMention = Vencord.Plugins.isPluginEnabled("NoReplyMention") + ? NoReplyMention.shouldMention(msg, isShiftPress) + : !isShiftPress; + FluxDispatcher.dispatch({ type: "CREATE_PENDING_REPLY", channel, message: msg, - shouldMention: !Settings.plugins.NoReplyMention.enabled, + shouldMention, showMentionToggle: channel.guild_id !== null }); } diff --git a/src/plugins/reviewDB/index.tsx b/src/plugins/reviewDB/index.tsx index 0c3578b07..bcd0f163f 100644 --- a/src/plugins/reviewDB/index.tsx +++ b/src/plugins/reviewDB/index.tsx @@ -35,13 +35,25 @@ import { getCurrentUserInfo, readNotification } from "./reviewDbApi"; import { settings } from "./settings"; import { showToast } from "./utils"; -const guildPopoutPatch: NavContextMenuPatchCallback = (children, props: { guild: Guild, onClose(): void; }) => { +const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => { children.push( openReviewsModal(props.guild.id, props.guild.name)} + action={() => openReviewsModal(guild.id, guild.name)} + /> + ); +}; + +const userContextPatch: NavContextMenuPatchCallback = (children, { user }: { user?: User, onClose(): void; }) => { + if (!user) return; + children.push( + openReviewsModal(user.id, user.username)} /> ); }; @@ -53,7 +65,10 @@ export default definePlugin({ settings, contextMenus: { - "guild-header-popout": guildPopoutPatch + "guild-header-popout": guildPopoutPatch, + "guild-context": guildPopoutPatch, + "user-context": userContextPatch, + "user-profile-actions": userContextPatch }, patches: [ diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index 32579a803..7033591bd 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -41,8 +41,8 @@ export default definePlugin({ patches: [{ find: "getRelationshipCounts(){", replacement: { - match: /\.sortBy\(\i=>\i\.comparator\)/, - replace: "$&.sortBy((row) => $self.sortList(row))" + match: /\}\)\.sortBy\((.+?)\)\.value\(\)/, + replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()" } }, { find: ".Messages.FRIEND_REQUEST_CANCEL", @@ -53,10 +53,10 @@ export default definePlugin({ } }], - sortList(row: any) { + wrapSort(comparator: Function, row: any) { return row.type === 3 || row.type === 4 ? -this.getSince(row.user) - : row.comparator; + : comparator(row); }, getSince(user: User) { diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index ce6bd709b..b92839a9a 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -24,9 +24,14 @@ import definePlugin, { OptionType } from "@utils/types"; import style from "./index.css?managed"; -const BASE_URL = "https://raw.githubusercontent.com/AutumnVN/usrbg/main/usrbg.json"; +const API_URL = "https://usrbg.is-hardly.online/users"; -let data = {} as Record; +interface UsrbgApiReturn { + endpoint: string + bucket: string + prefix: string + users: Record +} const settings = definePluginSettings({ nitroFirst: { @@ -48,7 +53,7 @@ const settings = definePluginSettings({ export default definePlugin({ name: "USRBG", description: "Displays user banners from USRBG, allowing anyone to get a banner without Nitro", - authors: [Devs.AutumnVN, Devs.pylix, Devs.TheKodeToad], + authors: [Devs.AutumnVN, Devs.katlyn, Devs.pylix, Devs.TheKodeToad], settings, patches: [ { @@ -80,8 +85,7 @@ export default definePlugin({ } ], - - data, + data: null as UsrbgApiReturn | null, settingsAboutComponent: () => { return ( @@ -91,9 +95,9 @@ export default definePlugin({ voiceBackgroundHook({ className, participantUserId }: any) { if (className.includes("tile_")) { - if (data[participantUserId]) { + if (this.userHasBackground(participantUserId)) { return { - backgroundImage: `url(${data[participantUserId]})`, + backgroundImage: `url(${this.getImageUrl(participantUserId)})`, backgroundSize: "cover", backgroundPosition: "center", backgroundRepeat: "no-repeat" @@ -104,24 +108,35 @@ export default definePlugin({ useBannerHook({ displayProfile, user }: any) { if (displayProfile?.banner && settings.store.nitroFirst) return; - if (data[user.id]) return data[user.id]; + if (this.userHasBackground(user.id)) return this.getImageUrl(user.id); }, premiumHook({ userId }: any) { - if (data[userId]) return 2; + if (this.userHasBackground(userId)) return 2; }, shouldShowBadge({ displayProfile, user }: any) { - return displayProfile?.banner && (!data[user.id] || settings.store.nitroFirst); + return displayProfile?.banner && (!this.userHasBackground(user.id) || settings.store.nitroFirst); + }, + + userHasBackground(userId: string) { + return !!this.data?.users[userId]; + }, + + getImageUrl(userId: string): string|null { + if (!this.userHasBackground(userId)) return null; + + // We can assert that data exists because userHasBackground returned true + const { endpoint, bucket, prefix, users: { [userId]: etag } } = this.data!; + return `${endpoint}/${bucket}/${prefix}${userId}?${etag}`; }, async start() { enableStyle(style); - const res = await fetch(BASE_URL); + const res = await fetch(API_URL); if (res.ok) { - data = await res.json(); - this.data = data; + this.data = await res.json(); } } });