Merge branch 'dev' into feat/usercss

This commit is contained in:
Lewis Crichton 2024-01-07 00:21:11 +00:00 committed by GitHub
commit 2ae1a70f7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 140 additions and 66 deletions

View file

@ -18,5 +18,5 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1 - uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1
with: with:
target_repo_url: "git@codeberg.org:Ven/cord.git" target_repo_url: "git@codeberg.org:Vee/cord.git"
ssh_private_key: ${{ secrets.CODEBERG_SSH_PRIVATE_KEY }} ssh_private_key: ${{ secrets.CODEBERG_SSH_PRIVATE_KEY }}

View file

@ -1,7 +1,7 @@
{ {
"name": "vencord", "name": "vencord",
"private": "true", "private": "true",
"version": "1.6.5", "version": "1.6.6",
"description": "The cutest Discord client mod", "description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme", "homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": { "bugs": {

View file

@ -81,9 +81,12 @@ function HashLink({ repo, hash, disabled = false }: { repo: string, hash: string
function Changes({ updates, repo, repoPending }: CommonProps & { updates: typeof changes; }) { function Changes({ updates, repo, repoPending }: CommonProps & { updates: typeof changes; }) {
return ( return (
<Card style={{ padding: ".5em" }}> <Card style={{ padding: "0 0.5em" }}>
{updates.map(({ hash, author, message }) => ( {updates.map(({ hash, author, message }) => (
<div> <div style={{
marginTop: "0.5em",
marginBottom: "0.5em"
}}>
<code><HashLink {...{ repo, hash }} disabled={repoPending} /></code> <code><HashLink {...{ repo, hash }} disabled={repoPending} /></code>
<span style={{ <span style={{
marginLeft: "0.5em", marginLeft: "0.5em",
@ -113,7 +116,7 @@ function Updatable(props: CommonProps) {
</> </>
) : ( ) : (
<Forms.FormText className={Margins.bottom8}> <Forms.FormText className={Margins.bottom8}>
{isOutdated ? `There are ${updates.length} Updates` : "Up to Date!"} {isOutdated ? (updates.length === 1 ? "There is 1 Update" : `There are ${updates.length} Updates`) : "Up to Date!"}
</Forms.FormText> </Forms.FormText>
)} )}

View file

@ -82,7 +82,7 @@ export const streamContextPatch: NavContextMenuPatchCallback = (children, { stre
}; };
export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => { export const userContextPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => {
return addViewStreamContext(children, { userId: user.id }); if (user) return addViewStreamContext(children, { userId: user.id });
}; };
export default definePlugin({ export default definePlugin({

View file

@ -30,6 +30,8 @@ interface UserContextProps {
} }
const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => () => { const UserContextMenuPatch: NavContextMenuPatchCallback = (children, { user }: UserContextProps) => () => {
if (!user) return;
children.push( children.push(
<Menu.MenuItem <Menu.MenuItem
id="vc-copy-user-url" id="vc-copy-user-url"

View file

@ -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 <https://www.gnu.org/licenses/>.
*/
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
export default definePlugin({
name: "FixCodeblockGap",
description: "Removes the gap between codeblocks and text below it",
authors: [Devs.Grzesiek11],
patches: [
{
find: ".default.Messages.DELETED_ROLE_PLACEHOLDER",
replacement: {
match: String.raw`/^${"```"}(?:([a-z0-9_+\-.#]+?)\n)?\n*([^\n][^]*?)\n*${"```"}`,
replace: "$&\\n?",
},
},
],
});

View file

@ -36,62 +36,68 @@ function search(src: string, engine: string) {
open(engine + encodeURIComponent(src), "_blank"); open(engine + encodeURIComponent(src), "_blank");
} }
const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => { function makeSearchItem(src: string) {
if (!props) return; return (
const { reverseImageSearchType, itemHref, itemSrc } = props; <Menu.MenuItem
label="Search Image"
key="search-image"
id="search-image"
>
{Object.keys(Engines).map((engine, i) => {
const key = "search-image-" + engine;
return (
<Menu.MenuItem
key={key}
id={key}
label={
<Flex style={{ alignItems: "center", gap: "0.5em" }}>
<img
style={{
borderRadius: i >= 3 // Do not round Google, Yandex & SauceNAO
? "50%"
: void 0
}}
aria-hidden="true"
height={16}
width={16}
src={new URL("/favicon.ico", Engines[engine]).toString().replace("lens.", "")}
/>
{engine}
</Flex>
}
action={() => search(src, Engines[engine])}
/>
);
})}
<Menu.MenuItem
key="search-image-all"
id="search-image-all"
label={
<Flex style={{ alignItems: "center", gap: "0.5em" }}>
<OpenExternalIcon height={16} width={16} />
All
</Flex>
}
action={() => Object.values(Engines).forEach(e => search(src, e))}
/>
</Menu.MenuItem>
);
}
if (!reverseImageSearchType || reverseImageSearchType !== "img") return; const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
if (props?.reverseImageSearchType !== "img") return;
const src = itemHref ?? itemSrc; const src = props.itemHref ?? props.itemSrc;
const group = findGroupChildrenByChildId("copy-link", children); const group = findGroupChildrenByChildId("copy-link", children);
if (group) { group?.push(makeSearchItem(src));
group.push(( };
<Menu.MenuItem
label="Search Image" const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
key="search-image" if (!props?.src) return;
id="search-image"
> const group = findGroupChildrenByChildId("copy-native-link", children) ?? children;
{Object.keys(Engines).map((engine, i) => { group.push(makeSearchItem(props.src));
const key = "search-image-" + engine;
return (
<Menu.MenuItem
key={key}
id={key}
label={
<Flex style={{ alignItems: "center", gap: "0.5em" }}>
<img
style={{
borderRadius: i >= 3 // Do not round Google, Yandex & SauceNAO
? "50%"
: void 0
}}
aria-hidden="true"
height={16}
width={16}
src={new URL("/favicon.ico", Engines[engine]).toString().replace("lens.", "")}
/>
{engine}
</Flex>
}
action={() => search(src, Engines[engine])}
/>
);
})}
<Menu.MenuItem
key="search-image-all"
id="search-image-all"
label={
<Flex style={{ alignItems: "center", gap: "0.5em" }}>
<OpenExternalIcon height={16} width={16} />
All
</Flex>
}
action={() => Object.values(Engines).forEach(e => search(src, e))}
/>
</Menu.MenuItem>
));
}
}; };
export default definePlugin({ export default definePlugin({
@ -111,10 +117,12 @@ export default definePlugin({
], ],
start() { start() {
addContextMenuPatch("message", imageContextMenuPatch); addContextMenuPatch("message", messageContextMenuPatch);
addContextMenuPatch("image-context", imageContextMenuPatch);
}, },
stop() { stop() {
removeContextMenuPatch("message", imageContextMenuPatch); removeContextMenuPatch("message", messageContextMenuPatch);
removeContextMenuPatch("image-context", imageContextMenuPatch);
} }
}); });

View file

@ -19,14 +19,23 @@
import "./styles.css"; import "./styles.css";
import { addPreSendListener, removePreSendListener } from "@api/MessageEvents"; import { addPreSendListener, removePreSendListener } from "@api/MessageEvents";
import { definePluginSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles"; import { classNameFactory } from "@api/Styles";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import { getTheme, insertTextIntoChatInputBox, Theme } from "@utils/discord"; import { getTheme, insertTextIntoChatInputBox, Theme } from "@utils/discord";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
import definePlugin from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Button, ButtonLooks, ButtonWrapperClasses, Forms, Parser, Select, Tooltip, useMemo, useState } from "@webpack/common"; import { Button, ButtonLooks, ButtonWrapperClasses, Forms, Parser, Select, Tooltip, useMemo, useState } from "@webpack/common";
const settings = definePluginSettings({
replaceMessageContents: {
description: "Replace timestamps in message contents",
type: OptionType.BOOLEAN,
default: true,
},
});
function parseTime(time: string) { function parseTime(time: string) {
const cleanTime = time.slice(1, -1).replace(/(\d)(AM|PM)$/i, "$1 $2"); const cleanTime = time.slice(1, -1).replace(/(\d)(AM|PM)$/i, "$1 $2");
@ -116,9 +125,11 @@ function PickerModal({ rootProps, close }: { rootProps: ModalProps, close(): voi
export default definePlugin({ export default definePlugin({
name: "SendTimestamps", name: "SendTimestamps",
description: "Send timestamps easily via chat box button & text shortcuts. Read the extended description!", description: "Send timestamps easily via chat box button & text shortcuts. Read the extended description!",
authors: [Devs.Ven, Devs.Tyler], authors: [Devs.Ven, Devs.Tyler, Devs.Grzesiek11],
dependencies: ["MessageEventsAPI"], dependencies: ["MessageEventsAPI"],
settings: settings,
patches: [ patches: [
{ {
find: "ChannelTextAreaButtons", find: "ChannelTextAreaButtons",
@ -131,7 +142,9 @@ export default definePlugin({
start() { start() {
this.listener = addPreSendListener((_, msg) => { this.listener = addPreSendListener((_, msg) => {
msg.content = msg.content.replace(/`\d{1,2}:\d{2} ?(?:AM|PM)?`/gi, parseTime); if (settings.store.replaceMessageContents) {
msg.content = msg.content.replace(/`\d{1,2}:\d{2} ?(?:AM|PM)?`/gi, parseTime);
}
}); });
}, },

View file

@ -213,7 +213,7 @@ function applyRules(content: string): string {
if (stringRules) { if (stringRules) {
for (const rule of stringRules) { for (const rule of stringRules) {
if (!rule.find || !rule.replace) continue; if (!rule.find) continue;
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue; if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
content = ` ${content} `.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n")).replace(/^\s|\s$/g, ""); content = ` ${content} `.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n")).replace(/^\s|\s$/g, "");
@ -222,7 +222,7 @@ function applyRules(content: string): string {
if (regexRules) { if (regexRules) {
for (const rule of regexRules) { for (const rule of regexRules) {
if (!rule.find || !rule.replace) continue; if (!rule.find) continue;
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue; if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
try { try {

View file

@ -33,7 +33,7 @@ function VencordPopout(onClose: () => void) {
const pluginEntries = [] as ReactNode[]; const pluginEntries = [] as ReactNode[];
for (const plugin of Object.values(Vencord.Plugins.plugins)) { for (const plugin of Object.values(Vencord.Plugins.plugins)) {
if (plugin.toolboxActions) { if (plugin.toolboxActions && Vencord.Plugins.isPluginEnabled(plugin.name)) {
pluginEntries.push( pluginEntries.push(
<Menu.MenuGroup <Menu.MenuGroup
label={plugin.name} label={plugin.name}

View file

@ -169,6 +169,15 @@ export default definePlugin({
match: /let\{text:\i=""/, match: /let\{text:\i=""/,
replace: "return [null,null];$&" replace: "return [null,null];$&"
} }
},
// Add back "Show My Camera" context menu
{
find: '.default("MediaEngineWebRTC");',
replacement: {
match: /supports\(\i\)\{switch\(\i\)\{case (\i).Features/,
replace: "$&.DISABLE_VIDEO:return true;case $1.Features"
}
} }
], ],

View file

@ -399,6 +399,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "maisy", name: "maisy",
id: 257109471589957632n, id: 257109471589957632n,
}, },
Grzesiek11: {
name: "Grzesiek11",
id: 368475654662127616n,
},
} satisfies Record<string, Dev>); } satisfies Record<string, Dev>);
// iife so #__PURE__ works correctly // iife so #__PURE__ works correctly