feat(plugin): FixYoutubeEmbeds - fix UMG blocked embeds (#2116)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
988435714e
commit
1670733458
4 changed files with 49 additions and 0 deletions
5
src/plugins/fixYoutubeEmbeds.desktop/README.md
Normal file
5
src/plugins/fixYoutubeEmbeds.desktop/README.md
Normal file
|
@ -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)
|
14
src/plugins/fixYoutubeEmbeds.desktop/index.ts
Normal file
14
src/plugins/fixYoutubeEmbeds.desktop/index.ts
Normal file
|
@ -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]
|
||||||
|
});
|
26
src/plugins/fixYoutubeEmbeds.desktop/native.ts
Normal file
26
src/plugins/fixYoutubeEmbeds.desktop/native.ts
Normal file
|
@ -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 });
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -407,6 +407,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "Samwich",
|
name: "Samwich",
|
||||||
id: 976176454511509554n,
|
id: 976176454511509554n,
|
||||||
},
|
},
|
||||||
|
coolelectronics: {
|
||||||
|
name: "coolelectronics",
|
||||||
|
id: 696392247205298207n,
|
||||||
|
}
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
Loading…
Reference in a new issue