Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinRMC authored Jun 19, 2024
1 parent 88e96d2 commit dd0ea1e
Show file tree
Hide file tree
Showing 12 changed files with 226 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/plusplugins/Kyuuhachi's userplugins/Anammox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Anammox

Removes Nitro-exclusive stuff from various places:
- The shops above private chats
- The gift button in the chat box
- The "billing" section in settings

While this can be done with css, a plugin is able to do it much more thorougly — for example, the shops are still accessible via keyboard navigation.
100 changes: 100 additions & 0 deletions src/plusplugins/Kyuuhachi's userplugins/Anammox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";

export const settings = definePluginSettings({
dms: {
type: OptionType.BOOLEAN,
default: true,
description: "Remove shops above DMs list",
restartNeeded: true,
},
billing: {
type: OptionType.BOOLEAN,
default: true,
description: "Remove billing settings",
restartNeeded: true,
},
gift: {
type: OptionType.BOOLEAN,
default: true,
description: "Remove gift button",
restartNeeded: true,
},
emojiList: {
type: OptionType.BOOLEAN,
default: true,
description: "Remove unavailable categories from the emoji picker",
restartNeeded: true,
},
});

export default definePlugin({
name: "Anammox",
description: "A microbial process that plays an important part in the nitrogen cycle",
authors: [Devs.Kyuuhachi],
settings,

patches: [
{ // Above DMs, mouse nav
find: 'tutorialId:"direct-messages"',
replacement: [
{
match: /"premium"\)/,
replace: "$&&&undefined",
},
{
match: /"discord-shop"\)/,
replace: "$&&&undefined",
},
],
predicate: () => settings.store.dms,
},
{ // Above DMs, keyboard nav
find: ".default.hasLibraryApplication()&&!",
replacement: [
{
match: /\i\.Routes\.APPLICATION_STORE,/,
replace: "/*$&*/",
},
{
match: /\i\.Routes\.COLLECTIBLES_SHOP,/,
replace: "/*$&*/",
},
],
predicate: () => settings.store.dms,
},
{ // Settings, sidebar
find: "Messages.BILLING_SETTINGS",
replacement: {
match: /\{header:[^:,]*\.Messages.BILLING_SETTINGS,[^}]*\]},/,
replace: "/*$&*/"
},
predicate: () => settings.store.billing,
},
{ // Gift button
find: 'Messages.PREMIUM_GIFT_BUTTON_LABEL,"aria-haspopup":"dialog",onClick:',
replacement: {
match: /if\(\w+\)return null;/,
replace: "return null;",
},
predicate: () => settings.store.gift,
},
{ // Emoji list
find: "useEmojiGrid:function()",
replacement: {
match: /(\w+)=!\w+&&\w+.default.isEmojiCategoryNitroLocked\(\{[^}]*\}\);/,
replace: "$&$1||"
},
predicate: () => settings.store.emojiList,
},
{ // Emoji category list
find: "useEmojiCategories:function()",
replacement: {
match: /(?<=(\i)\.unshift\((\i)\):)(?=\1\.push\(\2\))/,
replace: "$2.isNitroLocked||"
},
predicate: () => settings.store.emojiList,
}
],
});
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).
56 changes: 56 additions & 0 deletions src/plusplugins/Kyuuhachi's userplugins/ColorMessage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { definePluginSettings } from "@api/Settings";
import * as Styles from "@api/Styles";
import { makeRange } from "@components/PluginSettings/components";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack";

const AuthorStore = findByPropsLazy("useNullableMessageAuthor", "useNullableMessageAuthor");

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);
},
});
11 changes: 11 additions & 0 deletions src/plusplugins/Kyuuhachi's userplugins/ColorMessage/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
: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)
)
}
3 changes: 3 additions & 0 deletions src/plusplugins/Kyuuhachi's userplugins/Title/README.md
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.
44 changes: 44 additions & 0 deletions src/plusplugins/Kyuuhachi's userplugins/Title/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy } from "@webpack";

const TitleManager = findByPropsLazy("setPageTitleNotificationCount", "flashPageTitle");
const rootTitle = { base: null as string | null };

export const settings = definePluginSettings({
title: {
type: OptionType.STRING,
default: "Vencord",
description: "Window title prefix",
onChange: setTitle,
},
});

function setTitle(v: string) {
rootTitle.base = v || null;
TitleManager.flashPageTitle({ messages: 0 })();
}

export default definePlugin({
name: "Title",
description: "Replaces the window title prefix",
authors: [Devs.Kyuuhachi],
settings,

patches: [
{
find: "setPageTitleNotificationCount:function()",
replacement: {
match: /(?<==)(?={base:)/,
replace: "$self.rootTitle??",
},
},
],

start() {
setTitle(settings.store.title);
},

rootTitle,
});

0 comments on commit dd0ea1e

Please sign in to comment.