mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-09 14:43:03 -04:00
IRCColors Allowing CustomUserColors
This commit is contained in:
parent
078bc546d0
commit
8ec570ebc4
11 changed files with 26 additions and 71 deletions
|
@ -81,23 +81,22 @@ export default definePlugin({
|
|||
patches: [
|
||||
{
|
||||
// this also affects name headers in chats outside of servers
|
||||
find: '"BaseUsername"',
|
||||
find: '="SYSTEM_TAG"',
|
||||
replacement: {
|
||||
match: /style:\i.{0,100}void 0:void 0/,
|
||||
replace: "style:{color:$self.colorIfServer(arguments[0])}"
|
||||
match: /(?<=\i.gradientClassName]\),style:.{0,80}:void 0,)/,
|
||||
replace: "style:{color:$self.colorIfServer(arguments[0])},"
|
||||
},
|
||||
noWarn: true,
|
||||
predicate: () => !Settings.plugins.IrcColors.enabled
|
||||
},
|
||||
{
|
||||
predicate: () => settings.store.dmList,
|
||||
find: "PrivateChannel.renderAvatar",
|
||||
replacement: {
|
||||
match: /(highlighted:\i,)/,
|
||||
replace: "$1style:{color:`${$self.colorDMList(arguments[0])}`},"
|
||||
},
|
||||
predicate: () => settings.store.dmList,
|
||||
},
|
||||
{
|
||||
predicate: () => settings.store.dmList,
|
||||
find: "!1,wrapContent",
|
||||
replacement: [
|
||||
{
|
||||
|
@ -109,6 +108,7 @@ export default definePlugin({
|
|||
replace: "style:style||{},"
|
||||
},
|
||||
],
|
||||
predicate: () => settings.store.dmList,
|
||||
},
|
||||
],
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ import { Clipboard, Toasts } from "@webpack/common";
|
|||
export default definePlugin({
|
||||
name: "BetterRoleDot",
|
||||
authors: [Devs.Ven, Devs.AutumnVN],
|
||||
description:
|
||||
"Copy role colour on RoleDot (accessibility setting) click. Also allows using both RoleDot and coloured names simultaneously",
|
||||
description: "Copy role colour on RoleDot (accessibility setting) click. Also allows using both RoleDot and coloured names simultaneously",
|
||||
|
||||
patches: [
|
||||
{
|
||||
|
|
|
@ -27,12 +27,6 @@ export default definePlugin({
|
|||
{
|
||||
find: '"ChannelAttachButton"',
|
||||
replacement: [
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /\.attachButtonInner,"aria-label":.{0,50},onDoubleClick:(.+?:void 0),.{0,30}?\.\.\.(\i),/,
|
||||
replace: "$&onClick:$1,onContextMenu:$2.onClick,",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
match: /\.attachButtonInner,"aria-label":.{0,50},onDoubleClick:(.+?:void 0),.{0,100}\},(\i)\).{0,100}children:\i/,
|
||||
replace: "$&,onClick:$1,onContextMenu:$2.onClick,",
|
||||
|
|
|
@ -49,18 +49,6 @@ export default definePlugin({
|
|||
{
|
||||
find: ".decorationGridItem,",
|
||||
replacement: [
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /(?<==)\i=>{let{children.{20,200}decorationGridItem/,
|
||||
replace: "$self.DecorationGridItem=$&",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /(?<==)\i=>{let{user:\i,avatarDecoration/,
|
||||
replace: "$self.DecorationGridDecoration=$&",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
match: /(?<==)\i=>{var{children.{20,200}decorationGridItem/,
|
||||
replace: "$self.DecorationGridItem=$&",
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import { getCustomColorString } from "@equicordplugins/customUserColors";
|
||||
import { hash as h64 } from "@intrnl/xxhash64";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
@ -66,7 +67,7 @@ export default definePlugin({
|
|||
{
|
||||
find: '="SYSTEM_TAG"',
|
||||
replacement: {
|
||||
match: /(?<=className:\i\.username,style:.{0,50}:void 0,)/,
|
||||
match: /(?<=\i.gradientClassName]\),style:.{0,80}:void 0,)/,
|
||||
replace: "style:{color:$self.calculateNameColorForMessageContext(arguments[0])},"
|
||||
}
|
||||
},
|
||||
|
@ -84,30 +85,36 @@ export default definePlugin({
|
|||
const userId: string | undefined = context?.message?.author?.id;
|
||||
const colorString = context?.author?.colorString;
|
||||
const color = calculateNameColorForUser(userId);
|
||||
const customColor = userId && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(userId, true) : null;
|
||||
|
||||
// Color preview in role settings
|
||||
if (context?.message?.channel_id === "1337" && userId === "313337")
|
||||
return colorString;
|
||||
return customColor ?? colorString;
|
||||
|
||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
||||
return colorString;
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
|
||||
return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString)
|
||||
? color
|
||||
: colorString;
|
||||
if (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) {
|
||||
return customColor ?? color;
|
||||
} else {
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
},
|
||||
calculateNameColorForListContext(context: any) {
|
||||
const id = context?.user?.id;
|
||||
const colorString = context?.colorString;
|
||||
const color = calculateNameColorForUser(id);
|
||||
const customColor = id && Settings.plugins.CustomUserColors.enabled ? getCustomColorString(id, true) : null;
|
||||
|
||||
if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) {
|
||||
return colorString;
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
|
||||
return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString)
|
||||
? color
|
||||
: colorString;
|
||||
if (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) {
|
||||
return customColor ?? color;
|
||||
} else {
|
||||
return customColor ?? colorString;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -66,12 +66,6 @@ export default definePlugin({
|
|||
{
|
||||
find: "{isSidebarVisible:",
|
||||
replacement: [
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /(?<=let\{className:(\i),.+?children):\[(\i\.useMemo[^}]+"aria-multiselectable")/,
|
||||
replace: ":[$1?.startsWith('members')?$self.render():null,$2",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
match: /(?<=var\{className:(\i),.+?children):\[(\i\.useMemo[^}]+"aria-multiselectable")/,
|
||||
replace: ":[$1?.startsWith('members')?$self.render():null,$2",
|
||||
|
|
|
@ -84,12 +84,6 @@ export default definePlugin({
|
|||
{
|
||||
find: ".USER_MENTION)",
|
||||
replacement: [
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /onContextMenu:\i,color:\i,\.\.\.\i(?=,children:)(?<=user:(\i),channel:(\i).{0,500}?)/,
|
||||
replace: "$&,color:$self.getColorInt($1?.id,$2?.id)",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
match: /(?<=onContextMenu:\i,color:)\i(?=\},\i\),\{children)(?<=user:(\i),channel:(\i).{0,500}?)/,
|
||||
replace: "$self.getColorInt($1?.id,$2?.id)",
|
||||
|
|
|
@ -56,7 +56,7 @@ export default definePlugin({
|
|||
{
|
||||
find: '?"@":""',
|
||||
replacement: {
|
||||
match: /(?<=children:)\(\i\?"@":""\)\+\i(?=,|\})/,
|
||||
match: /(?<=onContextMenu:\i,children:)\i\+\i/,
|
||||
replace: "$self.renderUsername(arguments[0])"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -28,14 +28,6 @@ export default definePlugin({
|
|||
patches: [{
|
||||
find: "#{intl::ACTIVITY_SETTINGS}",
|
||||
replacement: [
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /(?<=}\)([,;])(\i\.settings)\.forEach.+?(\i)\.push.+}\)}\))/,
|
||||
replace: (_, commaOrSemi, settings, elements) => "" +
|
||||
`${commaOrSemi}${settings}?.[0]==="CHANGELOG"` +
|
||||
`&&${elements}.push({section:"StartupTimings",label:"Startup Timings",element:$self.StartupTimingPage})`,
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
match: /(?<=}\)([,;])(\i\.settings)\.forEach.+?(\i)\.push.+\)\)\}\))(?=\)\})/,
|
||||
replace: (_, commaOrSemi, settings, elements) => "" +
|
||||
|
|
|
@ -42,13 +42,6 @@ export default definePlugin({
|
|||
{
|
||||
find: '="SYSTEM_TAG"',
|
||||
replacement: [
|
||||
{
|
||||
// Add next to username (compact mode)
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /className:\i\(\)\(\i\.className(?:,\i\.clickable)?,\i\)}\),(?=\i)/g,
|
||||
replace: "$&$self.CompactPronounsChatComponentWrapper(arguments[0]),",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
// Add next to username (compact mode)
|
||||
match: /className:\i\(\)\(\i\.className(?:,\i\.clickable)?,\i\)}\)\),(?=\i)/g,
|
||||
|
|
|
@ -194,12 +194,6 @@ export default definePlugin({
|
|||
{
|
||||
find: ".overlay:void 0,status:",
|
||||
replacement: [
|
||||
{
|
||||
// FIXME(Bundler spread transform related): Remove old compatiblity once enough time has passed, if they don't revert
|
||||
match: /avatarSrc:(\i),eventHandlers:(\i).+?"div",{...\2,/,
|
||||
replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openAvatar($1)},",
|
||||
noWarn: true
|
||||
},
|
||||
{
|
||||
match: /avatarSrc:(\i),eventHandlers:(\i).+?"div",.{0,100}className:\i,/,
|
||||
replace: "$&style:{cursor:\"pointer\"},onClick:()=>{$self.openAvatar($1)},",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue