2024-01-19 02:07:35 +01:00
|
|
|
/*
|
|
|
|
* Vencord, a Discord client mod
|
|
|
|
* Copyright (c) 2023 Vendicated and contributors
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
2024-03-13 21:45:45 +01:00
|
|
|
import { RendererSettings } from "@main/settings";
|
2024-01-19 02:07:35 +01:00
|
|
|
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://www.youtube.com/")) {
|
2024-03-13 21:45:45 +01:00
|
|
|
const settings = RendererSettings.store.plugins?.FixYoutubeEmbeds;
|
2024-01-19 02:07:35 +01:00
|
|
|
if (!settings?.enabled) return;
|
|
|
|
|
|
|
|
frame.executeJavaScript(`
|
|
|
|
new MutationObserver(() => {
|
2024-02-06 17:18:49 +01:00
|
|
|
if(
|
2024-02-08 19:55:48 +01:00
|
|
|
document.querySelector('div.ytp-error-content-wrap-subreason a[href*="www.youtube.com/watch?v="]')
|
2024-02-06 17:18:49 +01:00
|
|
|
) location.reload()
|
2024-01-19 02:07:35 +01:00
|
|
|
}).observe(document.body, { childList: true, subtree:true });
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|