diff --git a/src/main/csp/index.ts b/src/main/csp/index.ts index c3fb88698..813e47010 100644 --- a/src/main/csp/index.ts +++ b/src/main/csp/index.ts @@ -111,7 +111,7 @@ const patchCsp = (headers: PolicyMap) => { pushDirective("script-src", "'unsafe-inline'", "'unsafe-eval'"); for (const directive of ["style-src", "connect-src", "img-src", "font-src", "media-src", "worker-src"]) { - pushDirective(directive, "blob:", "data:", "vencord:"); + pushDirective(directive, "blob:", "data:", "vencord:", "vesktop:"); } for (const [host, directives] of Object.entries(NativeSettings.store.customCspRules)) { diff --git a/src/plugins/autoDndWhilePlaying.discordDesktop/README.md b/src/plugins/autoDndWhilePlaying.discordDesktop/README.md new file mode 100644 index 000000000..52a611801 --- /dev/null +++ b/src/plugins/autoDndWhilePlaying.discordDesktop/README.md @@ -0,0 +1,5 @@ +# AutoDNDWhilePlaying + +This plugin automatically updates your online status (online, idle, dnd) when launching games. + +It will change your status back to the prior status when the game is closed. diff --git a/src/plugins/autoDndWhilePlaying.discordDesktop/index.ts b/src/plugins/autoDndWhilePlaying.discordDesktop/index.ts new file mode 100644 index 000000000..faf238cd8 --- /dev/null +++ b/src/plugins/autoDndWhilePlaying.discordDesktop/index.ts @@ -0,0 +1,61 @@ +/* + * 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 { getUserSettingLazy } from "@api/UserSettings"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +let savedStatus: string | null; + +const StatusSettings = getUserSettingLazy("status", "status")!; + +const settings = definePluginSettings({ + statusToSet: { + type: OptionType.SELECT, + description: "Status to set while playing a game", + options: [ + { + label: "Online", + value: "online", + }, + { + label: "Idle", + value: "idle", + }, + { + label: "Do Not Disturb", + value: "dnd", + default: true + }, + { + label: "Invisible", + value: "invisible", + } + ] + } +}); + +export default definePlugin({ + name: "AutoDNDWhilePlaying", + description: "Automatically updates your online status (online, idle, dnd) when launching games", + authors: [Devs.thororen], + settings, + flux: { + RUNNING_GAMES_CHANGE({ games }) { + const status = StatusSettings.getSetting(); + + if (games.length > 0) { + if (status !== settings.store.statusToSet) { + savedStatus = status; + StatusSettings.updateSetting(settings.store.statusToSet); + } + } else if (savedStatus && savedStatus !== settings.store.statusToSet) { + StatusSettings.updateSetting(savedStatus); + } + } + } +}); diff --git a/src/plugins/quickReply/index.ts b/src/plugins/quickReply/index.ts index ec991340d..ca930e986 100644 --- a/src/plugins/quickReply/index.ts +++ b/src/plugins/quickReply/index.ts @@ -21,7 +21,7 @@ import { Devs, IS_MAC } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Message } from "@vencord/discord-types"; import { MessageFlags } from "@vencord/discord-types/enums"; -import { ChannelStore, ComponentDispatch, FluxDispatcher as Dispatcher, MessageActions, MessageStore, MessageTypeSets, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { ChannelStore, ComponentDispatch, FluxDispatcher as Dispatcher, MessageActions, MessageStore, MessageTypeSets, PermissionsBits, PermissionStore, RelationshipStore, SelectedChannelStore, UserStore } from "@webpack/common"; import NoBlockedMessagesPlugin from "plugins/noBlockedMessages"; import NoReplyMentionPlugin from "plugins/noReplyMention"; @@ -40,13 +40,18 @@ const settings = definePluginSettings({ description: "Ping reply by default", options: [ { - label: "Follow NoReplyMention", + label: "Follow NoReplyMention plugin (if enabled)", value: MentionOptions.NO_REPLY_MENTION_PLUGIN, default: true }, { label: "Enabled", value: MentionOptions.ENABLED }, { label: "Disabled", value: MentionOptions.DISABLED }, ] + }, + ignoreBlockedAndIgnored: { + type: OptionType.BOOLEAN, + description: "Ignore messages by blocked/ignored users when navigating", + default: true } }); @@ -126,7 +131,7 @@ function jumpIfOffScreen(channelId: string, messageId: string) { } function getNextMessage(isUp: boolean, isReply: boolean) { - let messages: Array = MessageStore.getMessages(SelectedChannelStore.getChannelId())._array; + let messages: Message[] = MessageStore.getMessages(SelectedChannelStore.getChannelId())._array; const meId = UserStore.getCurrentUser().id; const hasNoBlockedMessages = Vencord.Plugins.isPluginEnabled(NoBlockedMessagesPlugin.name); @@ -134,8 +139,9 @@ function getNextMessage(isUp: boolean, isReply: boolean) { messages = messages.filter(m => { if (m.deleted) return false; if (!isReply && m.author.id !== meId) return false; // editing only own messages - if (hasNoBlockedMessages && NoBlockedMessagesPlugin.isBlocked(m)) return false; if (!MessageTypeSets.REPLYABLE.has(m.type) || m.hasFlag(MessageFlags.EPHEMERAL)) return false; + if (settings.store.ignoreBlockedAndIgnored && RelationshipStore.isBlockedOrIgnored(m.author.id)) return false; + if (hasNoBlockedMessages && NoBlockedMessagesPlugin.isBlocked(m)) return false; return true; });