diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/ipcPlugins.ts | 22 |
1 files changed, 22 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)\/.+$/; |