FixYTEmbeds: This Fix Sucks
This commit is contained in:
parent
4f5935be9b
commit
ac439b6207
2 changed files with 7 additions and 16 deletions
|
|
@ -29,6 +29,7 @@ export default definePlugin({
|
||||||
description: "Bypasses youtube videos being blocked from display on Discord (for example by UMG)",
|
description: "Bypasses youtube videos being blocked from display on Discord (for example by UMG)",
|
||||||
tags: ["Media", "Utility"],
|
tags: ["Media", "Utility"],
|
||||||
authors: [Devs.coolelectronics, Devs.arHSM],
|
authors: [Devs.coolelectronics, Devs.arHSM],
|
||||||
|
isModified: true,
|
||||||
settings,
|
settings,
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,23 +5,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RendererSettings } from "@main/settings";
|
import { RendererSettings } from "@main/settings";
|
||||||
import { app } from "electron";
|
import { app, session } from "electron";
|
||||||
|
|
||||||
app.on("browser-window-created", (_, win) => {
|
app.whenReady().then(() => {
|
||||||
win.webContents.on("frame-created", (_, { frame }) => {
|
session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ["https://www.youtube.com/embed/*"] }, ({ requestHeaders, resourceType }, callback) => {
|
||||||
frame?.once("dom-ready", () => {
|
if (resourceType === "subFrame" && RendererSettings.store.plugins?.FixYoutubeEmbeds?.enabled)
|
||||||
if (frame.url.startsWith("https://www.youtube.com/")) {
|
requestHeaders.Referer = "https://media.discordapp.com/";
|
||||||
const settings = RendererSettings.store.plugins?.FixYoutubeEmbeds;
|
|
||||||
if (!settings?.enabled) return;
|
|
||||||
|
|
||||||
frame.executeJavaScript(`
|
callback({ requestHeaders });
|
||||||
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 });
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue