feat(plugin): FixYoutubeEmbeds - fix UMG blocked embeds (#2116)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
988435714e
commit
1670733458
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",
|
||||
id: 976176454511509554n,
|
||||
},
|
||||
coolelectronics: {
|
||||
name: "coolelectronics",
|
||||
id: 696392247205298207n,
|
||||
}
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
Loading…
Reference in a new issue