Improve compatibility (#7)

This commit is contained in:
sepro
2025-10-18 01:25:19 +02:00
committed by GitHub
parent 689764f8ce
commit c38bd7d1ab

View File

@@ -1,9 +1,36 @@
import { parse } from "meriyah";
export const setupNodes = parse(`
globalThis.XMLHttpRequest = { prototype: {} };
const window = Object.assign(Object.create(null), globalThis);
window.location = new URL("https://www.youtube.com/watch?v=yt-dlp-wins");
const document = {};
let self = globalThis;
if (typeof globalThis.XMLHttpRequest === "undefined") {
globalThis.XMLHttpRequest = { prototype: {} };
}
if (typeof globalThis.window === "undefined") {
globalThis.window = Object.create(null);
}
if (typeof URL === "undefined") {
globalThis.window.location = {
hash: "",
host: "www.youtube.com",
hostname: "www.youtube.com",
href: "https://www.youtube.com/watch?v=yt-dlp-wins",
origin: "https://www.youtube.com",
password: "",
pathname: "/watch",
port: "",
protocol: "https:",
search: "?v=yt-dlp-wins",
username: "",
};
} else {
globalThis.window.location = new URL("https://www.youtube.com/watch?v=yt-dlp-wins");
}
if (typeof globalThis.document === "undefined") {
globalThis.document = Object.create(null);
}
if (typeof globalThis.navigator === "undefined") {
globalThis.navigator = Object.create(null);
}
if (typeof globalThis.self === "undefined") {
globalThis.self = globalThis;
}
`).body;