diff --git a/src/yt/solver/setup.ts b/src/yt/solver/setup.ts index 0266bb3..f0b3324 100644 --- a/src/yt/solver/setup.ts +++ b/src/yt/solver/setup.ts @@ -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;