This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/verticalsync/Suncord
- Loading branch information
Showing
28 changed files
with
979 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# ColorMessage | ||
|
||
An addon to RoleColorEverywhere, which colors message contents based on the sender's color, with configurable intensity. | ||
This uses [`color-mix`](https://caniuse.com/mdn-css_types_color_color-mix), which is not supported by the Electron Discord client (I don't know about Vesktop). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2024 Vendicated and contributors | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
import { definePluginSettings } from "@api/Settings"; | ||
import * as Styles from "@api/Styles"; | ||
import { makeRange } from "@components/PluginSettings/components"; | ||
import definePlugin, { OptionType } from "@utils/types"; | ||
import { findByPropsLazy } from "@webpack"; | ||
|
||
const AuthorStore = findByPropsLazy("useNullableMessageAuthor", "useNullableMessageAuthor"); | ||
|
||
import { Devs } from "@utils/constants"; | ||
|
||
import style from "./style.css?managed"; | ||
|
||
export const settings = definePluginSettings({ | ||
saturation: { | ||
type: OptionType.SLIDER, | ||
description: "Message color saturation", | ||
markers: makeRange(0, 100, 10), | ||
default: 20, | ||
onChange() { | ||
updateStyle(); | ||
}, | ||
}, | ||
}); | ||
|
||
function updateStyle() { | ||
(Styles.requireStyle(style).dom!.sheet!.cssRules[0] as CSSStyleRule) | ||
.style.setProperty("--98-message-color-saturation", `${settings.store.saturation}`); | ||
} | ||
|
||
export default definePlugin({ | ||
name: "ColorMessage", | ||
description: "Colors message content with author's role color", | ||
authors: [Devs.Kyuuhachi], | ||
settings, | ||
|
||
patches: [ | ||
{ | ||
find: 'default.Messages.MESSAGE_EDITED,")"', | ||
replacement: { | ||
match: /id:\(0,\w+.getMessageContentId\)\((\w+)\),/, | ||
replace: '$&style:{"--98-message-color":$self.getMessageColor($1)},' | ||
} | ||
}, | ||
], | ||
|
||
getMessageColor(messageId: string) { | ||
return AuthorStore.default(messageId).colorString; | ||
}, | ||
|
||
start() { | ||
Styles.enableStyle(style); | ||
updateStyle(); | ||
}, | ||
stop() { | ||
Styles.disableStyle(style); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* stylelint-disable custom-property-pattern */ | ||
:root { | ||
--98-message-color-saturation: /*DYNAMIC*/; | ||
} | ||
|
||
div[class*="messageContent_"] { | ||
color: color-mix( | ||
in lab, | ||
var(--98-message-color, var(--text-normal)) calc(var(--98-message-color-saturation) * 1%), | ||
var(--text-normal) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2024 Vendicated and contributors | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
import { Devs } from "@utils/constants"; | ||
import definePlugin from "@utils/types"; | ||
import { ChannelStore, GuildMemberStore, useStateFromStores } from "@webpack/common"; | ||
|
||
export default definePlugin({ | ||
name: "DeadMembers", | ||
description: "Shows when the sender of a message has left the guild", | ||
authors: [Devs.Kyuuhachi], | ||
|
||
patches: [ | ||
{ | ||
find: "UsernameDecorationTypes:function()", | ||
replacement: { | ||
match: /children:(\(\i\?"@":""\)\+\i)/, | ||
replace: "children:$self.wrapMessageAuthor(arguments[0],$1)" | ||
} | ||
}, | ||
{ | ||
find: "Messages.FORUM_POST_AUTHOR_A11Y_LABEL", | ||
replacement: { | ||
match: /(?<=\}=(\i),\{(user:\i,author:\i)\}=.{0,400}?\(\i\.Fragment,{children:)\i(?=}\),)/, | ||
replace: "$self.wrapForumAuthor({...$1,$2},$&)" | ||
} | ||
}, | ||
], | ||
|
||
wrapMessageAuthor({ author, message }, text) { | ||
const channel = ChannelStore.getChannel(message.channel_id); | ||
return message.webhookId | ||
? text | ||
: <DeadIndicator | ||
channel={channel} | ||
userId={message.author.id} | ||
text={text} | ||
/>; | ||
}, | ||
|
||
wrapForumAuthor({ channel, user }, text) { | ||
return <DeadIndicator | ||
channel={channel} | ||
userId={user.id} | ||
text={text} | ||
/>; | ||
}, | ||
}); | ||
|
||
|
||
function DeadIndicator({ channel, userId, text }) { | ||
const isMember = useStateFromStores( | ||
[GuildMemberStore], | ||
() => GuildMemberStore.isMember(channel?.guild_id, userId), | ||
); | ||
return channel?.guild_id && !isMember ? <s className="c98-author-dead">{text}</s> : text; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2024 Vendicated and contributors | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
import { Devs } from "@utils/constants"; | ||
import definePlugin from "@utils/types"; | ||
|
||
export default definePlugin({ | ||
name: "ImageLink", | ||
description: "Suppresses the hiding of links for \"simple embeds\"", | ||
authors: [Devs.Kyuuhachi], | ||
|
||
patches: [ | ||
{ | ||
find: "isEmbedInline:function", | ||
replacement: { | ||
match: /(?<=isEmbedInline:function\(\)\{return )\w+(?=\})/, | ||
replace: "()=>false", | ||
}, | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2024 Vendicated and contributors | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
import "./style.css"; | ||
|
||
import ErrorBoundary from "@components/ErrorBoundary"; | ||
import { Devs } from "@utils/constants"; | ||
import { proxyLazy } from "@utils/lazy"; | ||
import definePlugin from "@utils/types"; | ||
import { findComponentByCodeLazy } from "@webpack"; | ||
import { ChannelStore, Forms, MessageStore, RestAPI, Tooltip, useEffect, useState, useStateFromStores } from "@webpack/common"; | ||
import type { ComponentType, HTMLAttributes } from "react"; | ||
|
||
declare enum SpinnerTypes { | ||
WANDERING_CUBES = "wanderingCubes", | ||
CHASING_DOTS = "chasingDots", | ||
PULSING_ELLIPSIS = "pulsingEllipsis", | ||
SPINNING_CIRCLE = "spinningCircle", | ||
SPINNING_CIRCLE_SIMPLE = "spinningCircleSimple", | ||
LOW_MOTION = "lowMotion", | ||
} | ||
|
||
type Spinner = ComponentType<Omit<HTMLAttributes<HTMLDivElement>, "children"> & { | ||
type?: SpinnerTypes; | ||
animated?: boolean; | ||
className?: string; | ||
itemClassName?: string; | ||
"aria-label"?: string; | ||
}> & { | ||
Type: typeof SpinnerTypes; | ||
}; | ||
|
||
const { Spinner } = proxyLazy(() => Forms as any as { | ||
Spinner: Spinner, | ||
SpinnerTypes: typeof SpinnerTypes; | ||
}); | ||
|
||
const ChannelMessage = findComponentByCodeLazy("renderSimpleAccessories)") as ComponentType<any>; | ||
|
||
export default definePlugin({ | ||
name: "MessageLinkTooltip", | ||
description: "Like MessageLinkEmbed but without taking space", | ||
authors: [Devs.Kyuuhachi], | ||
|
||
patches: [ | ||
{ | ||
find: ',className:"channelMention",children:[', | ||
replacement: { | ||
match: /(?<=\.jsxs\)\()(\i\.default)/, | ||
replace: "$self.wrapComponent(arguments[0], $1)" | ||
} | ||
} | ||
], | ||
|
||
wrapComponent({ messageId, channelId }, Component: ComponentType) { | ||
return props => { | ||
if (messageId === undefined) return <Component {...props} />; | ||
return <Tooltip | ||
tooltipClassName="c98-message-link-tooltip" | ||
text={ | ||
<ErrorBoundary> | ||
<MessagePreview | ||
channelId={channelId} | ||
messageId={messageId} | ||
/> | ||
</ErrorBoundary> | ||
} | ||
> | ||
{({ onMouseEnter, onMouseLeave }) => | ||
<Component | ||
{...props} | ||
onMouseEnter={onMouseEnter} | ||
onMouseLeave={onMouseLeave} | ||
/> | ||
} | ||
</Tooltip>; | ||
}; | ||
} | ||
}); | ||
|
||
function MessagePreview({ channelId, messageId }) { | ||
const channel = ChannelStore.getChannel(channelId); | ||
const message = useMessage(channelId, messageId); | ||
// TODO handle load failure | ||
if (!message) { | ||
return <Spinner type={Spinner.Type.PULSING_ELLIPSIS} />; | ||
} | ||
|
||
return <ChannelMessage | ||
id={`message-link-tooltip-${messageId}`} | ||
message={message} | ||
channel={channel} | ||
subscribeToComponentDispatch={false} | ||
/>; | ||
} | ||
|
||
function useMessage(channelId, messageId) { | ||
const cachedMessage = useStateFromStores( | ||
// @ts-ignore | ||
[MessageStore], | ||
() => MessageStore.getMessage(channelId, messageId) | ||
); | ||
const [message, setMessage] = useState(cachedMessage); | ||
useEffect(() => { | ||
if (message == null) | ||
(async () => { | ||
const res = await RestAPI.get({ | ||
url: `/channels/${channelId}/messages`, | ||
query: { | ||
limit: 1, | ||
around: messageId, | ||
}, | ||
retries: 2, | ||
}); | ||
const rawMessage = res.body[0]; | ||
const message = MessageStore.getMessages(channelId) | ||
.receiveMessage(rawMessage) | ||
.get(messageId); | ||
setMessage(message); | ||
})(); | ||
}); | ||
return message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.c98-message-link-tooltip { | ||
width: max-content; | ||
max-width: 80vw; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Title | ||
|
||
In the browser version, the window/tab title is always prefixed with "Discord -". This plugin lets you change or remove this prefix. |
Oops, something went wrong.