diff --git a/src/plugins/fixYoutubeEmbeds.desktop/README.md b/src/plugins/fixYoutubeEmbeds.desktop/README.md new file mode 100644 index 00000000..875de9e2 --- /dev/null +++ b/src/plugins/fixYoutubeEmbeds.desktop/README.md @@ -0,0 +1,5 @@ +# FixYoutubeEmbeds + +Bypasses youtube videos being blocked from display on Discord (for example by UMG) + +![](https://github.com/Vendicated/Vencord/assets/45497981/7a5fdcaa-217c-4c63-acae-f0d6af2f79be) diff --git a/src/plugins/fixYoutubeEmbeds.desktop/index.ts b/src/plugins/fixYoutubeEmbeds.desktop/index.ts new file mode 100644 index 00000000..55486d76 --- /dev/null +++ b/src/plugins/fixYoutubeEmbeds.desktop/index.ts @@ -0,0 +1,14 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "FixYoutubeEmbeds", + description: "Bypasses youtube videos being blocked from display on Discord (for example by UMG)", + authors: [Devs.coolelectronics] +}); diff --git a/src/plugins/fixYoutubeEmbeds.desktop/native.ts b/src/plugins/fixYoutubeEmbeds.desktop/native.ts new file mode 100644 index 00000000..5a3ef2c6 --- /dev/null +++ b/src/plugins/fixYoutubeEmbeds.desktop/native.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 { app } from "electron"; +import { getSettings } from "main/ipcMain"; + +app.on("browser-window-created", (_, win) => { + win.webContents.on("frame-created", (_, { frame }) => { + frame.once("dom-ready", () => { + if (frame.url.startsWith("https://www.youtube.com/")) { + const settings = getSettings().plugins?.FixYoutubeEmbeds; + if (!settings?.enabled) return; + + frame.executeJavaScript(` + new MutationObserver(() => { + let err = document.querySelector(".ytp-error-content-wrap-subreason span")?.textContent; + if (err && err.includes("blocked it from display")) window.location.reload() + }).observe(document.body, { childList: true, subtree:true }); + `); + } + }); + }); +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 699c40b9..89993612 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -407,6 +407,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({ name: "Samwich", id: 976176454511509554n, }, + coolelectronics: { + name: "coolelectronics", + id: 696392247205298207n, + } } satisfies Record); // iife so #__PURE__ works correctly