From a04bfa578d1d3b34eb46851ac758f7310d76b030 Mon Sep 17 00:00:00 2001 From: Jakub Bednarski <45859721+Leon135@users.noreply.github.com> Date: Sun, 7 Jun 2026 19:10:14 +0200 Subject: [PATCH] fix(bGL) (#1158) * fix(bGL) * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/equicordplugins/betterGifLoad/index.ts | 24 ++++++++----------- .../streaks/stores/AuthorizationStore.tsx | 1 + src/main/utils/constants.ts | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/equicordplugins/betterGifLoad/index.ts b/src/equicordplugins/betterGifLoad/index.ts index 571a434ea..a1dd6c692 100644 --- a/src/equicordplugins/betterGifLoad/index.ts +++ b/src/equicordplugins/betterGifLoad/index.ts @@ -24,8 +24,7 @@ const qualities = [ { giphy: "100", tenor: "A2", cap: 120, video: "P4" }, // Horrible ~ 120 ]; -const mediaTenorLinkRegex = /^https:\/\/(?:media\d?|c)\.tenor\.com(?:\/m)?\/(?.+?)(?.{2})\/(?[^/]+)\./i; -const mediaTenorVideoLinkRegex = /^https:\/\/(?:media\d?|c)\.tenor\.com(?:\/m)?\/(?.+?)(?P\w{1,2})\/(?[^/]+)\.(?:mp4|webm)$/i; +const mediaTenorRegex = /^https:\/\/(?:media\d?|c)\.tenor\.com(?:\/m)?\/(?.+?)(?\w{2})\/(?[^/]+)\.(?gif|webp|mp4|webm)$/i; const giphyLinkRegex = /^https:\/\/media\d?\.giphy\.com\/media\/.*?\/(?.*?)\/giphy/i; const mediaProxyParser = /^https:\/\/images-ext-\d\.discordapp.net\/external\/.*?\.*?\/(?.*?)\/(?.*?)$/i; @@ -66,15 +65,15 @@ export default definePlugin({ }, { match: /(GIF_PICKER_QUERY_SUCCESS.{0,200}width:(\i),height:(\i),)src:(\i\(\i\)),gifSrc:(\i\(\i\))/, - replace: "$1src:$self.parseLink($4,[$2,$3]),gifSrc:$self.parseLink($5,[$2,$3])", + replace: "$1src:$self.parseLink($4,[$2,$3],true),gifSrc:$self.parseLink($5,[$2,$3],true)", }, { match: /(GIF_PICKER_TRENDING_FETCH_SUCCESS.{0,400})src:(\i\(\i\.trendingGIFPreview\.src\))/, - replace: "$1src:$self.parseLink($2)", + replace: "$1src:$self.parseLink($2,undefined,true)", }, { match: /src:(\i\(\i\.src\))(,type:\i\.\i\.TRENDING_CATEGORY,)/, - replace: "src:$self.parseLink($1)$2", + replace: "src:$self.parseLink($1,undefined,true)$2", }, ] }, @@ -92,21 +91,18 @@ export default definePlugin({ ], }, ], - parseLink(link: string, sizes?: [width: number, height: number]) { + parseLink(link: string, sizes?: [width: number, height: number], forceImage?: boolean) { const quality = settings.store.gifQuality; const q = qualities[quality - 1] ?? qualities[0]; const url: URL = new URL(link.startsWith("//") ? `https:${link}` : link); const cleanLink = getCleanLink(link); - const tenorVideoMatch = cleanLink.match(mediaTenorVideoLinkRegex); - if (tenorVideoMatch) { - const { id, name } = tenorVideoMatch.groups!; - return `https://media.tenor.com/${id}${q.video}/${name}.mp4`; - } - const tenorMatch = cleanLink.match(mediaTenorLinkRegex); + + const tenorMatch = cleanLink.match(mediaTenorRegex); if (tenorMatch) { - const { id, name } = tenorMatch.groups!; - return `https://media.tenor.com/${id}${q.tenor}/${name}.webp`; + const { id, name, ext } = tenorMatch.groups!; + const isVideo = !forceImage && (ext === "mp4" || ext === "webm"); + return `https://media.tenor.com/${id}${isVideo ? q.video : q.tenor}/${name}.${isVideo ? ext : "webp"}`; } const giphyMatch = cleanLink.match(giphyLinkRegex); diff --git a/src/equicordplugins/streaks/stores/AuthorizationStore.tsx b/src/equicordplugins/streaks/stores/AuthorizationStore.tsx index 447a621e4..580cc0672 100644 --- a/src/equicordplugins/streaks/stores/AuthorizationStore.tsx +++ b/src/equicordplugins/streaks/stores/AuthorizationStore.tsx @@ -3,6 +3,7 @@ * Copyright (c) 2026 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ + import * as DataStore from "@api/DataStore"; import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; diff --git a/src/main/utils/constants.ts b/src/main/utils/constants.ts index 3250a51e0..6b28f8339 100644 --- a/src/main/utils/constants.ts +++ b/src/main/utils/constants.ts @@ -72,4 +72,4 @@ if (IS_DEV) { } }, 5000); } -} \ No newline at end of file +}