mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 20:52:06 +00:00
fix(downloader): fix pmd undefined
This commit is contained in:
@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user