mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-26 17:26:22 +00:00
828688b996
Co-authored-by: V <vendicated@riseup.net>
27 lines
961 B
TypeScript
27 lines
961 B
TypeScript
/*
|
|
* 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(() => {
|
|
if(
|
|
document.querySelector('div.ytp-error-content-wrap-subreason a[href*="www.youtube.com/watch?v="]')
|
|
) location.reload()
|
|
}).observe(document.body, { childList: true, subtree:true });
|
|
`);
|
|
}
|
|
});
|
|
});
|
|
});
|