diff options
author | V <vendicated@riseup.net> | 2023-08-21 16:58:45 +0200 |
---|---|---|
committer | V <vendicated@riseup.net> | 2023-08-21 16:59:32 +0200 |
commit | 0335e1ca59df34d1e6f689a8adb70d0a1eaf085a (patch) | |
tree | 99486e9351e4abe73d08790e42253112295b8277 | |
parent | 817f0f747314ec6491a77b9d7472a42e4cf0c7da (diff) | |
download | Vencord-0335e1ca59df34d1e6f689a8adb70d0a1eaf085a.tar.gz Vencord-0335e1ca59df34d1e6f689a8adb70d0a1eaf085a.tar.bz2 Vencord-0335e1ca59df34d1e6f689a8adb70d0a1eaf085a.zip |
new plugin FixSpotifyEmbeds: less loud embeds
-rw-r--r-- | src/main/ipcPlugins.ts | 22 | ||||
-rw-r--r-- | src/plugins/fixSpotifyEmbeds.desktop.ts | 26 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/main/ipcPlugins.ts b/src/main/ipcPlugins.ts index bcc0a1b..3034fb4 100644 --- a/src/main/ipcPlugins.ts +++ b/src/main/ipcPlugins.ts @@ -22,6 +22,28 @@ import { readFile } from "fs/promises"; import { request } from "https"; import { basename, normalize } from "path"; +import { getSettings } from "./ipcMain"; + +// FixSpotifyEmbeds +app.on("browser-window-created", (_, win) => { + win.webContents.on("frame-created", (_, { frame }) => { + frame.once("dom-ready", () => { + if (frame.url.startsWith("https://open.spotify.com/embed/")) { + const settings = getSettings().plugins?.FixSpotifyEmbeds; + if (!settings?.enabled) return; + + frame.executeJavaScript(` + const original = Audio.prototype.play; + Audio.prototype.play = function() { + this.volume = ${(settings.volume / 100) || 0.1}; + return original.apply(this, arguments); + } + `); + } + }); + }); +}); + // #region OpenInApp // These links don't support CORS, so this has to be native const validRedirectUrls = /^https:\/\/(spotify\.link|s\.team)\/.+$/; diff --git a/src/plugins/fixSpotifyEmbeds.desktop.ts b/src/plugins/fixSpotifyEmbeds.desktop.ts new file mode 100644 index 0000000..4419912 --- /dev/null +++ b/src/plugins/fixSpotifyEmbeds.desktop.ts @@ -0,0 +1,26 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { definePluginSettings } from "@api/Settings"; +import { makeRange } from "@components/PluginSettings/components"; +import { Devs } from "@utils/constants"; +import definePlugin, { OptionType } from "@utils/types"; + +// The entire code of this plugin can be found in ipcPlugins +export default definePlugin({ + name: "FixSpotifyEmbeds", + description: "Fixes spotify embeds being incredibly loud by letting you customise the volume", + authors: [Devs.Ven], + settings: definePluginSettings({ + volume: { + type: OptionType.SLIDER, + description: "The volume % to set for spotify embeds. Anything above 10% is veeeery loud", + markers: makeRange(0, 100, 10), + stickToMarkers: false, + default: 10 + } + }) +}); |