From 8bda3a1e6aa3285f3cd12c80821d72dac55e040d Mon Sep 17 00:00:00 2001 From: Ulysses Zhan Date: Mon, 27 May 2024 09:36:09 -0700 Subject: [PATCH 1/6] LoadingQuotes: more customization & custom quotes support (#1795) Co-authored-by: lewisakura Co-authored-by: Vendicated --- src/plugins/loadingQuotes/index.ts | 106 +++++++++++++-------------- src/plugins/loadingQuotes/quotes.txt | 37 ++++++++++ 2 files changed, 87 insertions(+), 56 deletions(-) create mode 100644 src/plugins/loadingQuotes/quotes.txt diff --git a/src/plugins/loadingQuotes/index.ts b/src/plugins/loadingQuotes/index.ts index 97178979c..7d85cc90b 100644 --- a/src/plugins/loadingQuotes/index.ts +++ b/src/plugins/loadingQuotes/index.ts @@ -18,88 +18,82 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; +import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; +import presetQuotesText from "file://quotes.txt"; -// These are Xor encrypted to prevent you from spoiling yourself when you read the source code. -// don't worry about it :P -const quotes = [ - "Eyrokac", - "Rdcg$l`'k|~n", - 'H`tf$d&iajo+d`{"', - "Sucqplh`(Eclhualva()&", - "Lncgmka'8KNMDC,shpanf'`x./,", - "Ioqweijnfn*IeuvfvAotkfxo./,", - 'Hd{#cp\x7Ft$)nbd!{lq%mig~*\x7Fh`v#mk&sm{gx nd#idjb(a\x7Ffao"bja&amdkge!Rloìkhf)hyedfjjb*\'^hzdrdmm$lu\'|ao+mnqw$fijxh~bbmg#Tjmîefd+fnp#lpkffz5', - "h", - "sijklm&cam*rot\"hjjq'|ak\x7F xmv#wc'ep*mawmvvlrb(|ynr>\"Aqq&cgg-\x7F ugoh%rom)e\x7Fhdpp%$", - 'Tnfb}"u\'~`nno!kp$vvhfzeyee"a}%Tfam*Xh`fls%Jboldos-"lj`&hn)~ce!`jcbct|)gdbhnf$wikm$zgaxkmc%afely+og"144?\'ign+iu%p$qisiefr gpfa$', - "Ndtfv%ahfgk+ghtf$|ir(|z' Oguaw&`ggdj mgw$|ir(me|n", - "(!ͣ³$͙ʐ'ͩ¹#", - "(ネ◗ロ◑,マ-2ャユ✬", - "Ynw#hjil(ze+psgwp|&sgmkr!", - "Tikmolh`(fl+a!dvjk\x7F'y|e\x7Fe/,-", - "3/3750?5><9>885:7", - "mdmt", - "Wdn`khc+(oxbeof", - 'Ig"zkp*\'g{*xolglj`&~g|*gowg/$mgt(Eclm`.#ticf{l*xed"wl`&Kangj igbhqn\'d`dn `v#lqrw{3%$bhv-h|)kangj_imwhlhb', - "Tscmw%Tnoa~x", - "I‘f#npus(ec`e!vl$lhsm{`ncu\"ekw&f(defeov-$Rnf|)sdu‘pf$wcam{ceg!vl$du'D`d~x-\"jw%oi(okht-\"DJP)Kags,!mq$du'A‐|n sg`akrkq)~jkdl#pj&diefbnf\"jp)&@F\\*{ltq#Hlhrp'", - "Ynw$v`&cg`dl fml`%rhlhs*", - "Dnl$p%qhz{s' hv$w%hh|aceg!;#gpvt(fl+cndea`&dg|fon&v#wjjqm(", - "\ud83d)pft`gs(ec`e!13$qojmz#", - "a!njcmr'ide~nu\"lb%rheoedldpz$lu'gbkr", - "dn\"zkp&kgo4", - "hnpqkw", - "sn\"fau", - "Sn\"tmqnh}}*musvkaw&flf&+ldv$w%lr{}*aulr#vlao|)cetn\"jp$", - "Dxkmc%ot(hhxomwwai'{hln", - "hd{#}js&(pe~'sg#gprb(3#\"", - "hd{b${", - "<;vqkijbq33271:56<3799?24944:", - "Thof$lu'ofdn,!qsefc'az*bnrcma+&Om{o+iu\"`khct$)bnrd\"bcdoi&", - "snofplkb{)c'r\"lod'|f*aurv#cpno`abchijklmno", - "Wdn`khc'|f*eghl{%" -]; +const presetQuotes = presetQuotesText.split("\n").map(quote => /^\s*[^#\s]/.test(quote) && quote.trim()).filter(Boolean) as string[]; +const noQuotesQuote = "Did you really disable all loading quotes? What a buffoon you are..."; const settings = definePluginSettings({ replaceEvents: { - description: "Replace Event Quotes too", + description: "Should this plugin also apply during events with special event themed quotes? (e.g. Halloween)", type: OptionType.BOOLEAN, default: true - } + }, + enablePluginPresetQuotes: { + description: "Enable the quotes preset by this plugin", + type: OptionType.BOOLEAN, + default: true + }, + enableDiscordPresetQuotes: { + description: "Enable Discord's preset quotes (including event quotes, during events)", + type: OptionType.BOOLEAN, + default: false + }, + additionalQuotes: { + description: "Additional custom quotes to possibly appear, separated by the below delimiter", + type: OptionType.STRING, + default: "", + }, + additionalQuotesDelimiter: { + description: "Delimiter for additional quotes", + type: OptionType.STRING, + default: "|", + }, }); export default definePlugin({ name: "LoadingQuotes", description: "Replace Discords loading quotes", - authors: [Devs.Ven, Devs.KraXen72], + authors: [Devs.Ven, Devs.KraXen72, Devs.UlyssesZhan], settings, patches: [ { - find: ".LOADING_DID_YOU_KNOW}", + find: ".LOADING_DID_YOU_KNOW", replacement: [ { - match: /"_loadingText",function\(\)\{/, - replace: "$&return $self.quote;", + match: /"_loadingText".+?(?=(\i)\[.{0,10}\.random)/, + replace: "$&$self.mutateQuotes($1)," }, { - match: /"_eventLoadingText",function\(\)\{/, - replace: "$&return $self.quote;", + match: /"_eventLoadingText".+?(?=(\i)\[.{0,10}\.random)/, + replace: "$&$self.mutateQuotes($1),", predicate: () => settings.store.replaceEvents } - ], + ] }, ], - xor(quote: string) { - const key = "read if cute"; - const codes = Array.from(quote, (s, i) => s.charCodeAt(0) ^ (i % key.length)); - return String.fromCharCode(...codes); - }, + mutateQuotes(quotes: string[]) { + try { + const { enableDiscordPresetQuotes, additionalQuotes, additionalQuotesDelimiter, enablePluginPresetQuotes } = settings.store; - get quote() { - return this.xor(quotes[Math.floor(Math.random() * quotes.length)]); + if (!enableDiscordPresetQuotes) + quotes.length = 0; + + + if (enablePluginPresetQuotes) + quotes.push(...presetQuotes); + + quotes.push(...additionalQuotes.split(additionalQuotesDelimiter).filter(Boolean)); + + if (!quotes.length) + quotes.push(noQuotesQuote); + } catch (e) { + new Logger("LoadingQuotes").error("Failed to mutate quotes", e); + } } }); diff --git a/src/plugins/loadingQuotes/quotes.txt b/src/plugins/loadingQuotes/quotes.txt new file mode 100644 index 000000000..cfb01350e --- /dev/null +++ b/src/plugins/loadingQuotes/quotes.txt @@ -0,0 +1,37 @@ +# Blank lines and lines starting with "#" are ignored + +Explode +Read if cute +Have a nice day! +Starting Lightcord... +Loading 0BDFDB.plugin.js... +Installing BetterDiscord... +h +shhhhh did you know that you're my favourite user? But don't tell the others!! +Today's video is sponsored by Raid Shadow Legends, one of the biggest mobile role-playing games of 2019 and it's totally free! +Never gonna give you up, Never gonna let you down +( ͡° ͜ʖ ͡°) +(ノ◕ヮ◕)ノ*:・゚✧ +You look so pretty today! +Thinking of a funny quote... +3.141592653589793 +meow +Welcome, friend +If you, or someone you love, has Ligma, please see the Ligma health line at https://bit.ly/ligma_hotline +Trans Rights +I’d just like to interject for a moment. What you’re refering to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. +You're doing good today! +Don't worry, it's nothing 9 cups of coffee couldn't solve! +�(repeat like 30 times) +a light amount of tomfoolery is okay +do you love? +horror +so eepy +So without further ado, let's just jump right into it! +Dying is absolutely safe +hey you! you're cute :)) +heya ~ +<:trolley:997086295010594867> +Time is gone, space is insane. Here it comes, here again. +sometimes it's okay to just guhhhhhhhhhhhhhh +Welcome to nginx! From c431b7d2ab095118f642e2aefdbae3b5de290592 Mon Sep 17 00:00:00 2001 From: nin0dev Date: Mon, 27 May 2024 20:21:12 -0400 Subject: [PATCH 2/6] fix(MessageLogger): correctly mark markdown headers red (#2511) Co-authored-by: vee --- src/plugins/messageLogger/deleteStyleText.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/messageLogger/deleteStyleText.css b/src/plugins/messageLogger/deleteStyleText.css index 3477ef229..a4e9a93c1 100644 --- a/src/plugins/messageLogger/deleteStyleText.css +++ b/src/plugins/messageLogger/deleteStyleText.css @@ -3,6 +3,11 @@ color: var(--status-danger, #f04747) !important; } +/* Markdown title highlighting */ +.messagelogger-deleted [class*="contents"] :is(h1, h2, h3) { + color: var(--status-danger, #f04747) !important; +} + /* Bot "thinking" text highlighting */ .messagelogger-deleted [class*="colorStandard"] { color: var(--status-danger, #f04747) !important; From c2f8837602d0bcb931f2cf3d743425e897ff1adf Mon Sep 17 00:00:00 2001 From: sunnie <78964224+sunnniee@users.noreply.github.com> Date: Tue, 28 May 2024 03:23:30 +0300 Subject: [PATCH 3/6] new plugin: MaskedLinkPaste (#2514) Co-authored-by: vee --- src/plugins/maskedLinkPaste/README.md | 5 ++++ src/plugins/maskedLinkPaste/index.ts | 36 +++++++++++++++++++++++++++ src/utils/constants.ts | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/plugins/maskedLinkPaste/README.md create mode 100644 src/plugins/maskedLinkPaste/index.ts diff --git a/src/plugins/maskedLinkPaste/README.md b/src/plugins/maskedLinkPaste/README.md new file mode 100644 index 000000000..30beccb64 --- /dev/null +++ b/src/plugins/maskedLinkPaste/README.md @@ -0,0 +1,5 @@ +# MaskedLinkPaste + +Pasting a link while you have text selected will paste your link as a masked link at that location + +![](https://github.com/Vendicated/Vencord/assets/78964224/1d3be2c6-7957-44c9-92ec-551069d46c02) diff --git a/src/plugins/maskedLinkPaste/index.ts b/src/plugins/maskedLinkPaste/index.ts new file mode 100644 index 000000000..dc8689928 --- /dev/null +++ b/src/plugins/maskedLinkPaste/index.ts @@ -0,0 +1,36 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants.js"; +import definePlugin from "@utils/types"; +import { findByPropsLazy } from "@webpack"; + +const linkRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/; + +const { SlateTransforms } = findByPropsLazy("SlateTransforms"); + +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, () => $&)" + } + }], + + handlePaste(editor, content: string, originalBehavior: () => void) { + if (content && linkRegex.test(content) && editor.operations?.[0]?.type === "remove_text") { + SlateTransforms.insertText( + editor, + `[${editor.operations[0].text}](${content})` + ); + } + else originalBehavior(); + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 2f686d69d..69953855f 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -186,7 +186,7 @@ export const Devs = /* #__PURE__*/ Object.freeze({ id: 296776625432035328n, }, TheSun: { - name: "ActuallyTheSun", + name: "sunnie", id: 406028027768733696n }, axyie: { From 5b35d7c644ce306a6a9b70d3a33b9583eaecad55 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 28 May 2024 02:35:40 +0200 Subject: [PATCH 4/6] fix occasional errors in Dearrow & ImageZoom --- src/plugins/dearrow/index.tsx | 4 ++-- src/plugins/imageZoom/components/Magnifier.tsx | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/plugins/dearrow/index.tsx b/src/plugins/dearrow/index.tsx index 888e2bb45..89199da8f 100644 --- a/src/plugins/dearrow/index.tsx +++ b/src/plugins/dearrow/index.tsx @@ -182,8 +182,8 @@ export default definePlugin({ // add dearrow button { - match: /children:\[(?=null!=\i\?\i\.renderSuppressButton)/, - replace: "children:[$self.renderButton(this),", + match: /children:\[(?=null!=\i\?(\i)\.renderSuppressButton)/, + replace: "children:[$self.renderButton($1),", predicate: () => !settings.store.hideButton } ] diff --git a/src/plugins/imageZoom/components/Magnifier.tsx b/src/plugins/imageZoom/components/Magnifier.tsx index aadd0903a..585026d60 100644 --- a/src/plugins/imageZoom/components/Magnifier.tsx +++ b/src/plugins/imageZoom/components/Magnifier.tsx @@ -67,15 +67,18 @@ export const Magnifier = ErrorBoundary.wrap(({ instance, size: i } }; const syncVideos = () => { - currentVideoElementRef.current!.currentTime = originalVideoElementRef.current!.currentTime; + if (currentVideoElementRef.current && originalVideoElementRef.current) + currentVideoElementRef.current.currentTime = originalVideoElementRef.current.currentTime; }; const updateMousePosition = (e: MouseEvent) => { + if (!element.current) return; + if (instance.state.mouseOver && instance.state.mouseDown) { const offset = size.current / 2; const pos = { x: e.pageX, y: e.pageY }; - const x = -((pos.x - element.current!.getBoundingClientRect().left) * zoom.current - offset); - const y = -((pos.y - element.current!.getBoundingClientRect().top) * zoom.current - offset); + const x = -((pos.x - element.current.getBoundingClientRect().left) * zoom.current - offset); + const y = -((pos.y - element.current.getBoundingClientRect().top) * zoom.current - offset); setLensPosition({ x: e.x - offset, y: e.y - offset }); setImagePosition({ x, y }); setOpacity(1); @@ -184,6 +187,7 @@ export const Magnifier = ErrorBoundary.wrap(({ instance, size: i src={originalVideoElementRef.current?.src ?? instance.props.src} autoPlay loop + muted /> ) : ( Date: Tue, 28 May 2024 09:15:48 +0700 Subject: [PATCH 5/6] USRBG: support new simplified profile (#2501) Co-authored-by: vee --- src/plugins/usrbg/index.tsx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/plugins/usrbg/index.tsx b/src/plugins/usrbg/index.tsx index b92839a9a..1221cb9c5 100644 --- a/src/plugins/usrbg/index.tsx +++ b/src/plugins/usrbg/index.tsx @@ -27,10 +27,10 @@ import style from "./index.css?managed"; const API_URL = "https://usrbg.is-hardly.online/users"; interface UsrbgApiReturn { - endpoint: string - bucket: string - prefix: string - users: Record + endpoint: string; + bucket: string; + prefix: string; + users: Record; } const settings = definePluginSettings({ @@ -73,6 +73,19 @@ export default definePlugin({ } ] }, + { + find: /overrideBannerSrc:\i,profileType:/, + replacement: [ + { + match: /(\i)\.premiumType/, + replace: "$self.premiumHook($1)||$&" + }, + { + match: /(?<=function \i\((\i)\)\{)(?=var.{30,50},overrideBannerSrc:)/, + replace: "$1.overrideBannerSrc=$self.useBannerHook($1);" + } + ] + }, { find: "\"data-selenium-video-tile\":", predicate: () => settings.store.voiceBackground, @@ -123,7 +136,7 @@ export default definePlugin({ return !!this.data?.users[userId]; }, - getImageUrl(userId: string): string|null { + getImageUrl(userId: string): string | null { if (!this.userHasBackground(userId)) return null; // We can assert that data exists because userHasBackground returned true From b9e83d9d28efba44935d242b1e2cded6510be431 Mon Sep 17 00:00:00 2001 From: Lexi <72424960+KontrollFreek@users.noreply.github.com> Date: Mon, 27 May 2024 22:22:42 -0400 Subject: [PATCH 6/6] new plugin DontRoundMyTimestamps: round 7.6y -> 7y instead of 8y (#2060) Co-authored-by: V --- src/plugins/dontRoundMyTimestamps/index.ts | 35 ++++++++++++++++++++++ src/utils/constants.ts | 4 +++ 2 files changed, 39 insertions(+) create mode 100644 src/plugins/dontRoundMyTimestamps/index.ts diff --git a/src/plugins/dontRoundMyTimestamps/index.ts b/src/plugins/dontRoundMyTimestamps/index.ts new file mode 100644 index 000000000..4c432c73f --- /dev/null +++ b/src/plugins/dontRoundMyTimestamps/index.ts @@ -0,0 +1,35 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { moment } from "@webpack/common"; + +export default definePlugin({ + name: "DontRoundMyTimestamps", + authors: [Devs.Lexi], + description: "Always rounds relative timestamps down, so 7.6y becomes 7y instead of 8y", + + start() { + moment.relativeTimeRounding(Math.floor); + }, + + stop() { + moment.relativeTimeRounding(Math.round); + } +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 69953855f..4e3422526 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -402,6 +402,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "maisy", id: 257109471589957632n, }, + Lexi: { + name: "Lexi", + id: 506101469787717658n + }, Mopi: { name: "Mopi", id: 1022189106614243350n