Fix silent market CSV export
This commit is contained in:
+22
-1
@@ -39,15 +39,18 @@ export async function bootContentScript(
|
||||
return null;
|
||||
}
|
||||
|
||||
installMarketPageBridge(currentDocument);
|
||||
|
||||
const authState = await readAuthState(sendAuthMessage);
|
||||
if (!authState?.isAuthenticated) {
|
||||
await waitForBodyReady(currentDocument, currentWindow);
|
||||
renderMarketAuthGate(currentDocument, currentWindow);
|
||||
return {
|
||||
ready: Promise.resolve()
|
||||
};
|
||||
}
|
||||
|
||||
installMarketPageBridge(currentDocument);
|
||||
await waitForBodyReady(currentDocument, currentWindow);
|
||||
|
||||
return controllerFactory({
|
||||
document: currentDocument,
|
||||
@@ -144,6 +147,24 @@ function createRuntimeMessageSender(): (message: unknown) => Promise<unknown> {
|
||||
};
|
||||
}
|
||||
|
||||
async function waitForBodyReady(document: Document, currentWindow: Window): Promise<void> {
|
||||
if (document.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
const handleReady = () => {
|
||||
if (document.body) {
|
||||
document.removeEventListener("DOMContentLoaded", handleReady);
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", handleReady);
|
||||
currentWindow.setTimeout(handleReady, 0);
|
||||
});
|
||||
}
|
||||
|
||||
function downloadCsv(document: Document, window: Window, csv: string): void {
|
||||
const blob = new Blob(["\uFEFF", csv], {
|
||||
type: "text/csv;charset=utf-8"
|
||||
|
||||
Reference in New Issue
Block a user