diff --git a/src/api/Badges.ts b/src/api/Badges.ts index a1d7a0c62..e343a9930 100644 --- a/src/api/Badges.ts +++ b/src/api/Badges.ts @@ -51,7 +51,7 @@ export interface ProfileBadge { /** * Allows dynamically returning multiple badges. - * May call hooks but then you must not use shouldShow + * Must not call hooks */ getBadges?(userInfo: BadgeUserArgs): ProfileBadge[]; } diff --git a/src/plugins/_api/badges/index.tsx b/src/plugins/_api/badges/index.tsx index 59f78f671..41955d33e 100644 --- a/src/plugins/_api/badges/index.tsx +++ b/src/plugins/_api/badges/index.tsx @@ -133,16 +133,12 @@ export default definePlugin({ { find: "#{intl::PROFILE_USER_BADGES}", replacement: [ - { - match: /(?<=\{[^}]*?)badges:\i(?=[^}]*?}=(\i))/, - replace: "_$&=$self.useBadges($1.displayProfile).concat($1.badges)" - }, { match: /alt:" ","aria-hidden":!0,src:.{0,50}(\i).iconSrc/, replace: "...$1.props,$&" }, { - match: /(?<="aria-label":(\i)\.description,.{0,200}?)children:/g, + match: /(?<=forceOpen:.{0,40}?\i\((\i)\.id\).{0,100}?)children:/, replace: "children:$1.component?$self.renderBadgeComponent({...$1}) :" }, // handle onClick and onContextMenu @@ -151,6 +147,13 @@ export default definePlugin({ replace: "...$self.getBadgeMouseEventHandlers($1),$&" } ] + }, + { + find: "getLegacyUsername(){", + replacement: { + match: /getBadges\(\)\{.{0,100}?return\[/, + replace: "$&...$self.getBadges(this)," + } } ], @@ -186,14 +189,13 @@ export default definePlugin({ clearInterval(intervalId); }, - // doesn't use hooks itself, but some plugins might do so in their getBadges function - useBadges(profile: { userId: string; guildId: string; }) { + getBadges(profile: { userId: string; guildId: string; }) { if (!profile) return []; try { return _getBadges(profile); } catch (e) { - new Logger("BadgeAPI#useBadges").error(e); + new Logger("BadgeAPI#getBadges").error(e); return []; } }, diff --git a/src/plugins/fixImagesQuality/index.tsx b/src/plugins/fixImagesQuality/index.tsx index d446e421e..527c8f416 100644 --- a/src/plugins/fixImagesQuality/index.tsx +++ b/src/plugins/fixImagesQuality/index.tsx @@ -60,11 +60,12 @@ export default definePlugin({ ); }, - getSrc(props: { src: string; mediaLayoutType: string; width: number; height: number; contentType: string; mosaicStyleAlt?: boolean; }, freeze?: boolean) { + getSrc(props: { src: string; width: number; height: number; contentType: string; mosaicStyleAlt?: boolean; trigger?: string; }, freeze?: boolean) { if (!props?.src) return; try { - const { contentType, height, mediaLayoutType, src, width, mosaicStyleAlt } = props; + const { contentType, height, src, width, mosaicStyleAlt, trigger } = props; + // Embed images do not have a content type set. // It's difficult to differentiate between images and videos. but mosaicStyleAlt seems exclusive to images const isImage = contentType?.startsWith("image/") ?? (typeof mosaicStyleAlt === "boolean"); @@ -73,9 +74,15 @@ export default definePlugin({ const url = new URL(src); if (!url.pathname.startsWith("/attachments/")) return; - url.searchParams.set("animated", String(!freeze)); + if (freeze) { + url.searchParams.set("animated", "false"); - if (!settings.store.originalImagesInChat && mediaLayoutType === "MOSAIC") { + if (url.pathname.endsWith(".gif")) + url.searchParams.set("format", "webp"); + } + + const isModal = !!trigger; + if (!settings.store.originalImagesInChat && !isModal) { // make sure the image is not too large const pixels = width * height; const limit = 2000 * 1200; diff --git a/src/plugins/platformIndicators/index.tsx b/src/plugins/platformIndicators/index.tsx index 28d0ed4d8..3923d1233 100644 --- a/src/plugins/platformIndicators/index.tsx +++ b/src/plugins/platformIndicators/index.tsx @@ -45,21 +45,9 @@ const { useStatusFillColor } = mapMangledModuleLazy(".concat(.5625*", { useStatusFillColor: filters.byCode(".hex") }); -interface IconFactoryOpts { - viewBox?: string; - width?: number; - height?: number; -} - -interface IconProps { - color: string; - tooltip: string; - small?: boolean; -} - -function Icon(path: string, opts?: IconFactoryOpts) { - return ({ color, tooltip, small }: IconProps) => ( - +function Icon(path: string, opts?: { viewBox?: string; width?: number; height?: number; }) { + return ({ color, tooltip, small }: { color: string; tooltip: string; small: boolean; }) => ( + {tooltipProps => ( { +const PlatformIcon = ({ platform, status, small }) => { const tooltip = platform === "embedded" ? "Console" : platform[0].toUpperCase() + platform.slice(1); diff --git a/src/plugins/replaceGoogleSearch/index.tsx b/src/plugins/replaceGoogleSearch/index.tsx index be96c819b..e12048b18 100644 --- a/src/plugins/replaceGoogleSearch/index.tsx +++ b/src/plugins/replaceGoogleSearch/index.tsx @@ -21,6 +21,7 @@ const DefaultEngines = { GitHub: "https://github.com/search?q=", Reddit: "https://www.reddit.com/search?q=", Wikipedia: "https://wikipedia.org/w/index.php?search=", + Startpage: "https://www.startpage.com/sp/search?query=" } as const; const enum ReplacementEngineValue { diff --git a/src/plugins/webScreenShareFixes.web/index.ts b/src/plugins/webScreenShareFixes.web/index.ts index cce00ec8f..165d7b720 100644 --- a/src/plugins/webScreenShareFixes.web/index.ts +++ b/src/plugins/webScreenShareFixes.web/index.ts @@ -4,14 +4,25 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; + +const settings = definePluginSettings({ + experimentalAV1Support: { + type: OptionType.BOOLEAN, + description: "Enable AV1 codec support. May cause issues like infinitely loading streams", + default: false + } +}); export default definePlugin({ name: "WebScreenShareFixes", authors: [Devs.Kaitlyn], description: "Removes 2500kbps bitrate cap on chromium and vesktop clients.", enabledByDefault: true, + settings, + patches: [ { find: "x-google-max-bitrate", @@ -30,9 +41,19 @@ export default definePlugin({ }, { match: /\i\?\[(\i\.\i)\.H265,\i\.\i\.H264,\i\.\i\.VP8,\i\.\i\.VP9\]/, - replace: "true?['AV1',$1.H265,$1.VP9,$1.H264,$1.VP8]" + replace: "true?$self.getCodecs($1)" } ] } - ] + ], + + getCodecs(Codecs: Record) { + const codecs = [Codecs.H265, Codecs.VP9, Codecs.H264, Codecs.VP8]; + + if (settings.store.experimentalAV1Support) { + codecs.unshift("AV1"); + } + + return codecs; + } });