/* * Vencord, a Discord client mod * Copyright (c) 2025 nin0dev * SPDX-License-Identifier: GPL-3.0-or-later */ import { RendererSettings } from "@main/settings"; 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/")) { const settings = RendererSettings.store.plugins?.SpotifyAddToQueue; if (!settings?.enabled) return; frame.executeJavaScript(` const interval = setInterval(() => { const actions = document.querySelector("[class^='PlayerControlsShort_playerControlsWrapper__']"); if(actions) { const addToQueueButton = document.createElement("button"); Object.assign(addToQueueButton.style, { position: "relative", top: "11px", left: "0px" }); addToQueueButton.classList.add('gIjhme'); addToQueueButton.title = "Add to queue"; addToQueueButton.addEventListener("click", () => { window.top.postMessage("vc-spotifyaddtoqueue__" + location.href.match(/https:\\/\\/open\\.spotify.com\\/embed\\/track\\/([a-zA-Z0-9]{0,200})\\?/ )[1], "*"); }); addToQueueButton.innerHTML = ''; actions.insertBefore(addToQueueButton, actions.firstChild); clearInterval(interval); } }, 100); `); } }); }); });