fix(downloader): fix pmd undefined

This commit is contained in:
Su-Yong
2025-02-14 21:23:19 +09:00
parent 151f067beb
commit 5de07b9a96

View File

@ -116,6 +116,11 @@ export const onMainLoad = async ({
const visitorData = yt.session.context.client.visitorData; const visitorData = yt.session.context.client.visitorData;
if (visitorData) { if (visitorData) {
const cleanUp = (context: Partial<typeof globalThis>) => {
delete context.window;
delete context.document;
};
try { try {
const [width, height] = win.getSize(); const [width, height] = win.getSize();
// emulate jsdom using linkedom // emulate jsdom using linkedom
@ -153,16 +158,16 @@ export const onMainLoad = async ({
program: bgChallenge.program, program: bgChallenge.program,
globalName: bgChallenge.globalName, globalName: bgChallenge.globalName,
bgConfig, bgConfig,
}).finally(() => {
cleanUp(globalThis);
}); });
yt.session.po_token = poTokenResult.poToken; yt.session.po_token = poTokenResult.poToken;
} else {
cleanUp(globalThis);
} }
} finally { } catch {
// Bypass TypeScript checks cleanUp(globalThis);
((x: Partial<typeof globalThis>) => {
delete x.window;
delete x.document;
})(globalThis);
} }
} }