mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-09 09:26:22 +00:00
Merge branch 'dev' into immediate-finds
This commit is contained in:
commit
f61b5ae058
6 changed files with 80 additions and 38 deletions
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Margins } from "@utils/margins";
|
||||
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||
import { OptionType, PluginOptionNumber } from "@utils/types";
|
||||
import { Forms, React, TextInput } from "@webpack/common";
|
||||
|
||||
|
@ -54,7 +56,8 @@ export function SettingNumericComponent({ option, pluginSettings, definedSetting
|
|||
|
||||
return (
|
||||
<Forms.FormSection>
|
||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
||||
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||
<Forms.FormText className={Margins.bottom20} type="description">{option.description}</Forms.FormText>
|
||||
<TextInput
|
||||
type="number"
|
||||
pattern="-?[0-9]+"
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Margins } from "@utils/margins";
|
||||
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||
import { PluginOptionSelect } from "@utils/types";
|
||||
import { Forms, React, Select } from "@webpack/common";
|
||||
|
||||
|
@ -44,7 +46,8 @@ export function SettingSelectComponent({ option, pluginSettings, definedSettings
|
|||
|
||||
return (
|
||||
<Forms.FormSection>
|
||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
||||
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||
<Forms.FormText className={Margins.bottom16} type="description">{option.description}</Forms.FormText>
|
||||
<Select
|
||||
isDisabled={option.disabled?.call(definedSettings) ?? false}
|
||||
options={option.options}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Margins } from "@utils/margins";
|
||||
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||
import { PluginOptionSlider } from "@utils/types";
|
||||
import { Forms, React, Slider } from "@webpack/common";
|
||||
|
||||
|
@ -50,7 +52,8 @@ export function SettingSliderComponent({ option, pluginSettings, definedSettings
|
|||
|
||||
return (
|
||||
<Forms.FormSection>
|
||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
||||
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||
<Forms.FormText className={Margins.bottom20} type="description">{option.description}</Forms.FormText>
|
||||
<Slider
|
||||
disabled={option.disabled?.call(definedSettings) ?? false}
|
||||
markers={option.markers}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Margins } from "@utils/margins";
|
||||
import { wordsFromCamel, wordsToTitle } from "@utils/text";
|
||||
import { PluginOptionString } from "@utils/types";
|
||||
import { Forms, React, TextInput } from "@webpack/common";
|
||||
|
||||
|
@ -41,7 +43,8 @@ export function SettingTextComponent({ option, pluginSettings, definedSettings,
|
|||
|
||||
return (
|
||||
<Forms.FormSection>
|
||||
<Forms.FormTitle>{option.description}</Forms.FormTitle>
|
||||
<Forms.FormTitle>{wordsToTitle(wordsFromCamel(id))}</Forms.FormTitle>
|
||||
<Forms.FormText className={Margins.bottom20} type="description">{option.description}</Forms.FormText>
|
||||
<TextInput
|
||||
type="text"
|
||||
value={state}
|
||||
|
|
|
@ -22,10 +22,12 @@ const NoopLogger = {
|
|||
fileOnly: Noop
|
||||
};
|
||||
|
||||
const logAllow = new Set();
|
||||
|
||||
const settings = definePluginSettings({
|
||||
disableNoisyLoggers: {
|
||||
disableLoggers: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Disable noisy loggers like the MessageActionCreators",
|
||||
description: "Disables Discords loggers",
|
||||
default: false,
|
||||
restartNeeded: true
|
||||
},
|
||||
|
@ -34,16 +36,33 @@ const settings = definePluginSettings({
|
|||
description: "Disable the Spotify logger, which leaks account information and access token",
|
||||
default: true,
|
||||
restartNeeded: true
|
||||
},
|
||||
whitelistedLoggers: {
|
||||
type: OptionType.STRING,
|
||||
description: "Semi colon separated list of loggers to allow even if others are hidden",
|
||||
default: "GatewaySocket; Routing/Utils",
|
||||
onChange(newVal: string) {
|
||||
logAllow.clear();
|
||||
newVal.split(";").map(x => x.trim()).forEach(logAllow.add.bind(logAllow));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "ConsoleJanitor",
|
||||
description: "Disables annoying console messages/errors",
|
||||
authors: [Devs.Nuckyz],
|
||||
authors: [Devs.Nuckyz, Devs.sadan],
|
||||
settings,
|
||||
|
||||
start() {
|
||||
logAllow.clear();
|
||||
this.settings.store.whitelistedLoggers?.split(";").map(x => x.trim()).forEach(logAllow.add.bind(logAllow));
|
||||
},
|
||||
|
||||
NoopLogger: () => NoopLogger,
|
||||
shouldLog(logger: string) {
|
||||
return logAllow.has(logger);
|
||||
},
|
||||
|
||||
patches: [
|
||||
{
|
||||
|
@ -103,34 +122,13 @@ export default definePlugin({
|
|||
replace: ""
|
||||
}
|
||||
},
|
||||
...[
|
||||
'("MessageActionCreators")', '("ChannelMessages")',
|
||||
'("Routing/Utils")', '("RTCControlSocket")',
|
||||
'("ConnectionEventFramerateReducer")', '("RTCLatencyTestManager")',
|
||||
'("OverlayBridgeStore")', '("RPCServer:WSS")', '("RPCServer:IPC")'
|
||||
].map(logger => ({
|
||||
find: logger,
|
||||
predicate: () => settings.store.disableNoisyLoggers,
|
||||
all: true,
|
||||
replacement: {
|
||||
match: new RegExp(String.raw`new \i\.\i${logger.replace(/([()])/g, "\\$1")}`),
|
||||
replace: `$self.NoopLogger${logger}`
|
||||
}
|
||||
})),
|
||||
// Patches discords generic logger function
|
||||
{
|
||||
find: '"Experimental codecs: "',
|
||||
predicate: () => settings.store.disableNoisyLoggers,
|
||||
find: "Σ:",
|
||||
predicate: () => settings.store.disableLoggers,
|
||||
replacement: {
|
||||
match: /new \i\.\i\("Connection\("\.concat\(\i,"\)"\)\)/,
|
||||
replace: "$self.NoopLogger()"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: '"_handleLocalVideoDisabled: ',
|
||||
predicate: () => settings.store.disableNoisyLoggers,
|
||||
replacement: {
|
||||
match: /new \i\.\i\("RTCConnection\("\.concat.+?\)\)(?=,)/,
|
||||
replace: "$self.NoopLogger()"
|
||||
match: /(?<=&&)(?=console)/,
|
||||
replace: "$self.shouldLog(arguments[0])&&"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -141,5 +139,5 @@ export default definePlugin({
|
|||
replace: "$self.NoopLogger()"
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
});
|
||||
|
|
|
@ -18,10 +18,14 @@
|
|||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { makeRange } from "@components/PluginSettings/components";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCode } from "@webpack";
|
||||
import { ChannelStore, GuildMemberStore, GuildStore } from "@webpack/common";
|
||||
|
||||
const useMessageAuthor = findByCode('"Result cannot be null because the message is not null"');
|
||||
|
||||
const settings = definePluginSettings({
|
||||
chatMentions: {
|
||||
type: OptionType.BOOLEAN,
|
||||
|
@ -46,13 +50,21 @@ const settings = definePluginSettings({
|
|||
default: true,
|
||||
description: "Show role colors in the reactors list",
|
||||
restartNeeded: true
|
||||
}
|
||||
},
|
||||
messageSaturation: {
|
||||
type: OptionType.SLIDER,
|
||||
description: "Intensity of message coloring. 0 to disable.",
|
||||
markers: makeRange(0, 100, 10),
|
||||
default: 30,
|
||||
// This is called only once at startup, but late enough that the store is initialized.
|
||||
get restartNeeded() { return settings.store.messageSaturation === 0; }
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
export default definePlugin({
|
||||
name: "RoleColorEverywhere",
|
||||
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN],
|
||||
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN, Devs.Kyuuhachi],
|
||||
description: "Adds the top role color anywhere possible",
|
||||
patches: [
|
||||
// Chat Mentions
|
||||
|
@ -114,7 +126,15 @@ export default definePlugin({
|
|||
replace: "$&,style:{color:$self.getColor($2?.id,$1)}"
|
||||
},
|
||||
predicate: () => settings.store.reactorsList,
|
||||
}
|
||||
},
|
||||
{
|
||||
find: '.Messages.MESSAGE_EDITED,")"',
|
||||
replacement: {
|
||||
match: /(?<=isUnsupported\]:(\i)\.isUnsupported\}\),)(?=children:\[)/,
|
||||
replace: "style:{color:$self.useMessageColor($1)},"
|
||||
},
|
||||
predicate: () => settings.store.messageSaturation !== 0,
|
||||
},
|
||||
],
|
||||
settings,
|
||||
|
||||
|
@ -148,5 +168,17 @@ export default definePlugin({
|
|||
color: this.getColor(userId, { guildId })
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
useMessageColor(message: any) {
|
||||
try {
|
||||
const { messageSaturation } = settings.use(["messageSaturation"]);
|
||||
const author = useMessageAuthor(message);
|
||||
if (author.colorString !== undefined && messageSaturation !== 0)
|
||||
return `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var(--text-normal))`;
|
||||
} catch (e) {
|
||||
console.error("[RCE] failed to get message color", e);
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue