From 5d1283bd85471f160d5220c67ad521379804f9d1 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 11 Mar 2023 14:18:32 +0100 Subject: Add Web/Desktop specific plugin capabilities; misc fixes --- src/plugins/arRPC.tsx | 107 ---------------------------------- src/plugins/arRPC.web.tsx | 109 +++++++++++++++++++++++++++++++++++ src/plugins/consoleShortcuts.ts | 8 +-- src/plugins/devCompanion.dev.tsx | 7 ++- src/plugins/noRPC.desktop.ts | 37 ++++++++++++ src/plugins/noRPC.ts | 38 ------------ src/plugins/noSystemBadge.desktop.ts | 41 +++++++++++++ src/plugins/noSystemBadge.ts | 42 -------------- src/plugins/richerCider.desktop.tsx | 67 +++++++++++++++++++++ src/plugins/richerCider.tsx | 67 --------------------- src/plugins/volumeBooster.desktop.ts | 86 +++++++++++++++++++++++++++ src/plugins/volumeBooster.ts | 86 --------------------------- src/plugins/webContextMenus.ts | 46 --------------- src/plugins/webContextMenus.web.ts | 46 +++++++++++++++ 14 files changed, 394 insertions(+), 393 deletions(-) delete mode 100644 src/plugins/arRPC.tsx create mode 100644 src/plugins/arRPC.web.tsx create mode 100644 src/plugins/noRPC.desktop.ts delete mode 100644 src/plugins/noRPC.ts create mode 100644 src/plugins/noSystemBadge.desktop.ts delete mode 100644 src/plugins/noSystemBadge.ts create mode 100644 src/plugins/richerCider.desktop.tsx delete mode 100644 src/plugins/richerCider.tsx create mode 100644 src/plugins/volumeBooster.desktop.ts delete mode 100644 src/plugins/volumeBooster.ts delete mode 100644 src/plugins/webContextMenus.ts create mode 100644 src/plugins/webContextMenus.web.ts (limited to 'src/plugins') diff --git a/src/plugins/arRPC.tsx b/src/plugins/arRPC.tsx deleted file mode 100644 index ca94a0e..0000000 --- a/src/plugins/arRPC.tsx +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 OpenAsar - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { popNotice, showNotice } from "@api/Notices"; -import { Link } from "@components/Link"; -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; -import { filters, findByCodeLazy, mapMangledModuleLazy } from "@webpack"; -import { FluxDispatcher, Forms, Toasts } from "@webpack/common"; - -const assetManager = mapMangledModuleLazy( - "getAssetImage: size must === [number, number] for Twitch", - { - getAsset: filters.byCode("apply("), - } -); - -const lookupRpcApp = findByCodeLazy(".APPLICATION_RPC("); - -async function lookupAsset(applicationId: string, key: string): Promise { - return (await assetManager.getAsset(applicationId, [key, undefined]))[0]; -} - -const apps: any = {}; -async function lookupApp(applicationId: string): Promise { - const socket: any = {}; - await lookupRpcApp(socket, applicationId); - return socket.application; -} - -let ws: WebSocket; -export default definePlugin({ - name: "WebRichPresence (arRPC)", - description: "Client plugin for arRPC to enable RPC on Discord Web (experimental)", - authors: [Devs.Ducko], - target: "WEB", - - settingsAboutComponent: () => ( - <> - How to use arRPC - - Follow the instructions in the GitHub repo to get the server running, and then enable the plugin. - - - ), - - async start() { - if (ws) ws.close(); - ws = new WebSocket("ws://127.0.0.1:1337"); // try to open WebSocket - - ws.onmessage = async e => { // on message, set status to data - const data = JSON.parse(e.data); - - if (data.activity?.assets?.large_image) data.activity.assets.large_image = await lookupAsset(data.activity.application_id, data.activity.assets.large_image); - if (data.activity?.assets?.small_image) data.activity.assets.small_image = await lookupAsset(data.activity.application_id, data.activity.assets.small_image); - - if (data.activity) { - const appId = data.activity.application_id; - apps[appId] ||= await lookupApp(appId); - - const app = apps[appId]; - data.activity.name ||= app.name; - } - - FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", ...data }); - }; - - const connectionSuccessful = await new Promise(res => setTimeout(() => res(ws.readyState === WebSocket.OPEN), 1000)); // check if open after 1s - if (!connectionSuccessful) { - showNotice("Failed to connect to arRPC, is it running?", "Retry", () => { // show notice about failure to connect, with retry/ignore - popNotice(); - this.start(); - }); - return; - } - - Toasts.show({ // show toast on success - message: "Connected to arRPC", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { - duration: 1000, - position: Toasts.Position.BOTTOM - } - }); - }, - - stop() { - FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: null }); // clear status - ws.close(); // close WebSocket - } -}); diff --git a/src/plugins/arRPC.web.tsx b/src/plugins/arRPC.web.tsx new file mode 100644 index 0000000..9a16c64 --- /dev/null +++ b/src/plugins/arRPC.web.tsx @@ -0,0 +1,109 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 OpenAsar + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { popNotice, showNotice } from "@api/Notices"; +import { Link } from "@components/Link"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { filters, findByCodeLazy, mapMangledModuleLazy } from "@webpack"; +import { FluxDispatcher, Forms, Toasts } from "@webpack/common"; + +const assetManager = mapMangledModuleLazy( + "getAssetImage: size must === [number, number] for Twitch", + { + getAsset: filters.byCode("apply("), + } +); + +const lookupRpcApp = findByCodeLazy(".APPLICATION_RPC("); + +async function lookupAsset(applicationId: string, key: string): Promise { + return (await assetManager.getAsset(applicationId, [key, undefined]))[0]; +} + +const apps: any = {}; +async function lookupApp(applicationId: string): Promise { + const socket: any = {}; + await lookupRpcApp(socket, applicationId); + return socket.application; +} + +let ws: WebSocket; +export default definePlugin({ + name: "WebRichPresence (arRPC)", + description: "Client plugin for arRPC to enable RPC on Discord Web (experimental)", + authors: [Devs.Ducko], + + settingsAboutComponent: () => ( + <> + How to use arRPC + + Follow the instructions in the GitHub repo to get the server running, and then enable the plugin. + + + ), + + async start() { + // ArmCord comes with its own arRPC implementation, so this plugin just confuses users + if ("armcord" in window) return; + + if (ws) ws.close(); + ws = new WebSocket("ws://127.0.0.1:1337"); // try to open WebSocket + + ws.onmessage = async e => { // on message, set status to data + const data = JSON.parse(e.data); + + if (data.activity?.assets?.large_image) data.activity.assets.large_image = await lookupAsset(data.activity.application_id, data.activity.assets.large_image); + if (data.activity?.assets?.small_image) data.activity.assets.small_image = await lookupAsset(data.activity.application_id, data.activity.assets.small_image); + + if (data.activity) { + const appId = data.activity.application_id; + apps[appId] ||= await lookupApp(appId); + + const app = apps[appId]; + data.activity.name ||= app.name; + } + + FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", ...data }); + }; + + const connectionSuccessful = await new Promise(res => setTimeout(() => res(ws.readyState === WebSocket.OPEN), 1000)); // check if open after 1s + if (!connectionSuccessful) { + showNotice("Failed to connect to arRPC, is it running?", "Retry", () => { // show notice about failure to connect, with retry/ignore + popNotice(); + this.start(); + }); + return; + } + + Toasts.show({ // show toast on success + message: "Connected to arRPC", + type: Toasts.Type.SUCCESS, + id: Toasts.genId(), + options: { + duration: 1000, + position: Toasts.Position.BOTTOM + } + }); + }, + + stop() { + FluxDispatcher.dispatch({ type: "LOCAL_ACTIVITY_UPDATE", activity: null }); // clear status + ws.close(); // close WebSocket + } +}); diff --git a/src/plugins/consoleShortcuts.ts b/src/plugins/consoleShortcuts.ts index 83b5291..70a9875 100644 --- a/src/plugins/consoleShortcuts.ts +++ b/src/plugins/consoleShortcuts.ts @@ -32,14 +32,14 @@ export default definePlugin({ authors: [Devs.Ven], getShortcuts() { - function newFindWrapper(filterFactory: (props: any) => Webpack.FilterFn) { - const cache = new Map(); + function newFindWrapper(filterFactory: (...props: any[]) => Webpack.FilterFn) { + const cache = new Map(); - return function (filterProps: any) { + return function (...filterProps: unknown[]) { const cacheKey = String(filterProps); if (cache.has(cacheKey)) return cache.get(cacheKey); - const matches = findAll(filterFactory(filterProps)); + const matches = findAll(filterFactory(...filterProps)); const result = (() => { switch (matches.length) { diff --git a/src/plugins/devCompanion.dev.tsx b/src/plugins/devCompanion.dev.tsx index 1dbf4ca..cea71e0 100644 --- a/src/plugins/devCompanion.dev.tsx +++ b/src/plugins/devCompanion.dev.tsx @@ -112,7 +112,7 @@ function initWs(isManual = false) { }); ws.addEventListener("close", e => { - if (!wasConnected && !hasErrored) return; + if (!wasConnected || hasErrored) return; logger.info("Dev Companion Disconnected:", e.code, e.reason); @@ -204,8 +204,9 @@ function initWs(isManual = false) { return reply("Unknown Find Type " + type); } - if (results.length === 0) throw "No results"; - if (results.length > 1) throw "Found more than one result! Make this filter more specific"; + const uniqueResultsCount = new Set(results).size; + if (uniqueResultsCount === 0) throw "No results"; + if (uniqueResultsCount > 1) throw "Found more than one result! Make this filter more specific"; } catch (err) { return reply("Failed to find: " + err); } diff --git a/src/plugins/noRPC.desktop.ts b/src/plugins/noRPC.desktop.ts new file mode 100644 index 0000000..ebd7b1a --- /dev/null +++ b/src/plugins/noRPC.desktop.ts @@ -0,0 +1,37 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { migratePluginSettings } from "@api/settings"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +migratePluginSettings("NoRPC", "No RPC"); +export default definePlugin({ + name: "NoRPC", + description: "Disables Discord's RPC server.", + authors: [Devs.Cyn], + patches: [ + { + find: '.ensureModule("discord_rpc")', + replacement: { + match: /\.ensureModule\("discord_rpc"\)\.then\(\(.+?\)\)}/, + replace: '.ensureModule("discord_rpc")}', + }, + }, + ], +}); diff --git a/src/plugins/noRPC.ts b/src/plugins/noRPC.ts deleted file mode 100644 index a78cc27..0000000 --- a/src/plugins/noRPC.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { migratePluginSettings } from "@api/settings"; -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -migratePluginSettings("NoRPC", "No RPC"); -export default definePlugin({ - name: "NoRPC", - description: "Disables Discord's RPC server.", - authors: [Devs.Cyn], - target: "DESKTOP", - patches: [ - { - find: '.ensureModule("discord_rpc")', - replacement: { - match: /\.ensureModule\("discord_rpc"\)\.then\(\(.+?\)\)}/, - replace: '.ensureModule("discord_rpc")}', - }, - }, - ], -}); diff --git a/src/plugins/noSystemBadge.desktop.ts b/src/plugins/noSystemBadge.desktop.ts new file mode 100644 index 0000000..591a0be --- /dev/null +++ b/src/plugins/noSystemBadge.desktop.ts @@ -0,0 +1,41 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "NoSystemBadge", + description: "Disables the taskbar and system tray unread count badge.", + authors: [Devs.rushii], + patches: [ + { + find: "setSystemTrayApplications:function", + replacement: [ + { + match: /setBadge:function.+?},/, + replace: "setBadge:function(){}," + }, + { + match: /setSystemTrayIcon:function.+?},/, + replace: "setSystemTrayIcon:function(){}," + } + ] + } + ] +}); diff --git a/src/plugins/noSystemBadge.ts b/src/plugins/noSystemBadge.ts deleted file mode 100644 index e487a97..0000000 --- a/src/plugins/noSystemBadge.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "NoSystemBadge", - description: "Disables the taskbar and system tray unread count badge.", - authors: [Devs.rushii], - target: "DESKTOP", - patches: [ - { - find: "setSystemTrayApplications:function", - replacement: [ - { - match: /setBadge:function.+?},/, - replace: "setBadge:function(){}," - }, - { - match: /setSystemTrayIcon:function.+?},/, - replace: "setSystemTrayIcon:function(){}," - } - ] - } - ] -}); diff --git a/src/plugins/richerCider.desktop.tsx b/src/plugins/richerCider.desktop.tsx new file mode 100644 index 0000000..8b6fb5e --- /dev/null +++ b/src/plugins/richerCider.desktop.tsx @@ -0,0 +1,67 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 OpenAsar + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Link } from "@components/Link"; +import definePlugin from "@utils/types"; +import { Forms } from "@webpack/common"; +const appIds = [ + "911790844204437504", + "886578863147192350", + "1020414178047041627", + "1032800329332445255" +]; +export default definePlugin({ + name: "richerCider", + description: "Enhances Cider (More details in info button) by adding the \"Listening to\" type prefix to the user's rich presence when an applicable ID is found.", + authors: [{ + id: 191621342473224192n, + name: "cryptofyre", + }], + patches: [ + { + find: '.displayName="LocalActivityStore"', + replacement: { + match: /LOCAL_ACTIVITY_UPDATE:function\((\i)\)\{/, + replace: "$&$self.patchActivity($1.activity);", + } + } + ], + settingsAboutComponent: () => ( + <> + Install Cider to use this Plugin + + Follow the link to our website to get Cider up and running, and then enable the plugin. + +

+ What is Cider? + + Cider is an open-source and community oriented Apple Music client for Windows, macOS, and Linux. + +

+ Recommended Optional Plugins + + I'd recommend using TimeBarAllActivities alongside this plugin to give off a much better visual to the eye (Keep in mind this only affects your client and will not show for other users) + + + ), + patchActivity(activity: any) { + if (appIds.includes(activity.application_id)) { + activity.type = 2; /* LISTENING type */ + } + }, +}); diff --git a/src/plugins/richerCider.tsx b/src/plugins/richerCider.tsx deleted file mode 100644 index 08b0096..0000000 --- a/src/plugins/richerCider.tsx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 OpenAsar - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { Link } from "@components/Link"; -import definePlugin from "@utils/types"; -import { Forms } from "@webpack/common"; -const appIds = [ - "911790844204437504", - "886578863147192350", - "1020414178047041627", - "1032800329332445255" -]; -export default definePlugin({ - name: "richerCider", - description: "Enhances Cider (More details in info button) by adding the \"Listening to\" type prefix to the user's rich presence when an applicable ID is found.", - authors: [{ - id: 191621342473224192n, - name: "cryptofyre", - }], - patches: [ - { - find: '.displayName="LocalActivityStore"', - replacement: { - match: /LOCAL_ACTIVITY_UPDATE:function\((\i)\)\{/, - replace: "$&$self.patchActivity($1.activity);", - } - } - ], - settingsAboutComponent: () => ( - <> - Install Cider to use this Plugin - - Follow the link to our website to get Cider up and running, and then enable the plugin. - -

- What is Cider? - - Cider is an open-source and community oriented Apple Music client for Windows, macOS, and Linux. - -

- Recommended Optional Plugins - - I'd recommend using TimeBarAllActivities alongside this plugin to give off a much better visual to the eye (Keep in mind this only affects your client and will not show for other users) - - - ), - patchActivity(activity: any) { - if (appIds.includes(activity.application_id)) { - activity.type = 2; /* LISTENING type */ - } - }, -}); diff --git a/src/plugins/volumeBooster.desktop.ts b/src/plugins/volumeBooster.desktop.ts new file mode 100644 index 0000000..7d81449 --- /dev/null +++ b/src/plugins/volumeBooster.desktop.ts @@ -0,0 +1,86 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { definePluginSettings } from "@api/settings"; +import { makeRange } from "@components/PluginSettings/components"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +const settings = definePluginSettings({ + multiplier: { + description: "Volume Multiplier", + type: OptionType.SLIDER, + markers: makeRange(1, 5, 1), + default: 2, + stickToMarkers: true, + } +}); + +export default definePlugin({ + name: "VolumeBooster", + authors: [Devs.Nuckyz], + description: "Allows you to set the user and stream volume above the default maximum.", + settings, + + patches: [ + // Change the max volume for sliders to allow for values above 200 + ...[ + ".Messages.USER_VOLUME", + "currentVolume:" + ].map(find => ({ + find, + replacement: { + match: /(?<=maxValue:\i\.\i)\?(\d+?):(\d+?)(?=,)/, + replace: (_, higherMaxVolume, minorMaxVolume) => "" + + `?${higherMaxVolume}*$self.settings.store.multiplier` + + `:${minorMaxVolume}*$self.settings.store.multiplier` + } + })), + // Prevent Audio Context Settings sync from trying to sync with values above 200, changing them to 200 before we send to Discord + { + find: "AudioContextSettingsMigrated", + replacement: [ + { + match: /(?<=updateAsync\("audioContextSettings".{0,50})(?=return (\i)\.volume=(\i))/, + replace: (_, volumeOptions, newVolume) => `if(${newVolume}>200)return ${volumeOptions}.volume=200;` + }, + { + match: /(?<=Object\.entries\(\i\.localMutes\).+?volume:).+?(?=,)/, + replace: "$&>200?200:$&" + }, + { + match: /(?<=Object\.entries\(\i\.localVolumes\).+?volume:).+?(?=})/, + replace: "$&>200?200:$&" + } + ] + }, + // Prevent the MediaEngineStore from overwriting our LocalVolumes above 200 with the ones the Discord Audio Context Settings sync sends + { + find: '.displayName="MediaEngineStore"', + replacement: [ + { + match: /(?<=\.settings\.audioContextSettings.+?)(\i\[\i\])=(\i\.volume)(.+?setLocalVolume\(\i,).+?\)/, + replace: (_, localVolume, syncVolume, rest) => "" + + `(${localVolume}>200?void 0:${localVolume}=${syncVolume})` + + rest + + `${localVolume}??${syncVolume})` + } + ] + } + ], +}); diff --git a/src/plugins/volumeBooster.ts b/src/plugins/volumeBooster.ts deleted file mode 100644 index 7d81449..0000000 --- a/src/plugins/volumeBooster.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { definePluginSettings } from "@api/settings"; -import { makeRange } from "@components/PluginSettings/components"; -import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; - -const settings = definePluginSettings({ - multiplier: { - description: "Volume Multiplier", - type: OptionType.SLIDER, - markers: makeRange(1, 5, 1), - default: 2, - stickToMarkers: true, - } -}); - -export default definePlugin({ - name: "VolumeBooster", - authors: [Devs.Nuckyz], - description: "Allows you to set the user and stream volume above the default maximum.", - settings, - - patches: [ - // Change the max volume for sliders to allow for values above 200 - ...[ - ".Messages.USER_VOLUME", - "currentVolume:" - ].map(find => ({ - find, - replacement: { - match: /(?<=maxValue:\i\.\i)\?(\d+?):(\d+?)(?=,)/, - replace: (_, higherMaxVolume, minorMaxVolume) => "" - + `?${higherMaxVolume}*$self.settings.store.multiplier` - + `:${minorMaxVolume}*$self.settings.store.multiplier` - } - })), - // Prevent Audio Context Settings sync from trying to sync with values above 200, changing them to 200 before we send to Discord - { - find: "AudioContextSettingsMigrated", - replacement: [ - { - match: /(?<=updateAsync\("audioContextSettings".{0,50})(?=return (\i)\.volume=(\i))/, - replace: (_, volumeOptions, newVolume) => `if(${newVolume}>200)return ${volumeOptions}.volume=200;` - }, - { - match: /(?<=Object\.entries\(\i\.localMutes\).+?volume:).+?(?=,)/, - replace: "$&>200?200:$&" - }, - { - match: /(?<=Object\.entries\(\i\.localVolumes\).+?volume:).+?(?=})/, - replace: "$&>200?200:$&" - } - ] - }, - // Prevent the MediaEngineStore from overwriting our LocalVolumes above 200 with the ones the Discord Audio Context Settings sync sends - { - find: '.displayName="MediaEngineStore"', - replacement: [ - { - match: /(?<=\.settings\.audioContextSettings.+?)(\i\[\i\])=(\i\.volume)(.+?setLocalVolume\(\i,).+?\)/, - replace: (_, localVolume, syncVolume, rest) => "" - + `(${localVolume}>200?void 0:${localVolume}=${syncVolume})` - + rest - + `${localVolume}??${syncVolume})` - } - ] - } - ], -}); diff --git a/src/plugins/webContextMenus.ts b/src/plugins/webContextMenus.ts deleted file mode 100644 index 6419cfd..0000000 --- a/src/plugins/webContextMenus.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2022 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import { Devs } from "@utils/constants"; -import definePlugin from "@utils/types"; - -export default definePlugin({ - name: "WebContextMenus", - description: "Re-adds some of context menu items missing on the web version of Discord, namely Copy/Open Link", - authors: [Devs.Ven], - target: "WEB", - - patches: [{ - // There is literally no reason for Discord to make this Desktop only. - // The only thing broken is copy, but they already have a different copy function - // with web support???? - find: "open-native-link", - replacement: [ - { - // if (isNative || null == - match: /if\(!\w\..{1,3}\|\|null==/, - replace: "if(null==" - }, - // Fix silly Discord calling the non web support copy - { - match: /\w\.default\.copy/, - replace: "Vencord.Webpack.Common.Clipboard.copy" - } - ] - }] -}); diff --git a/src/plugins/webContextMenus.web.ts b/src/plugins/webContextMenus.web.ts new file mode 100644 index 0000000..56990e1 --- /dev/null +++ b/src/plugins/webContextMenus.web.ts @@ -0,0 +1,46 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2022 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "WebContextMenus", + description: "Re-adds some of context menu items missing on the web version of Discord, namely Copy/Open Link", + authors: [Devs.Ven], + enabledByDefault: true, + + patches: [{ + // There is literally no reason for Discord to make this Desktop only. + // The only thing broken is copy, but they already have a different copy function + // with web support???? + find: "open-native-link", + replacement: [ + { + // if (isNative || null == + match: /if\(!\w\..{1,3}\|\|null==/, + replace: "if(null==" + }, + // Fix silly Discord calling the non web support copy + { + match: /\w\.default\.copy/, + replace: "Vencord.Webpack.Common.Clipboard.copy" + } + ] + }] +}); -- cgit