2023-11-09 01:32:34 +00:00
|
|
|
/*
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
* Copyright (c) 2023 Vendicated and contributors
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
2024-03-13 20:45:45 +00:00
|
|
|
import { RendererSettings } from "@main/settings";
|
2023-11-09 01:32:34 +00:00
|
|
|
import { app } from "electron";
|
|
|
|
|
|
|
|
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/")) {
|
2024-03-13 20:45:45 +00:00
|
|
|
const settings = RendererSettings.store.plugins?.FixSpotifyEmbeds;
|
2023-11-09 01:32:34 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|