diff --git a/src/login.ts b/src/login.ts index 3796950..ac76bc4 100644 --- a/src/login.ts +++ b/src/login.ts @@ -4,8 +4,6 @@ export async function login(page: Page, email: string): Promise { console.log("Navigating to Perplexity..."); await page.goto("https://www.perplexity.ai/"); - await page.click("button::-p-text('Accept All Cookies')"); - // Wait for email input and enter credentials await page.waitForSelector('input[type="email"]'); await page.type('input[type="email"]', email); diff --git a/src/utils.ts b/src/utils.ts index b1c5bdd..a3f24d2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,7 +5,16 @@ export async function loadDoneFile(doneFilePath: string): Promise { try { const content = await fs.readFile(doneFilePath, "utf-8"); return JSON.parse(content); - } catch (error) { + } catch (error: any) { + if (error.code === "ENOENT") { + const defaultDoneFile = { processedUrls: [] }; + console.log(`Created empty ${doneFilePath}`); + await fs.writeFile( + doneFilePath, + JSON.stringify(defaultDoneFile, null, 2), + ); + return defaultDoneFile; + } console.error(`Error loading done file ${doneFilePath}:`, error); return { processedUrls: [] }; } @@ -13,7 +22,7 @@ export async function loadDoneFile(doneFilePath: string): Promise { export async function saveDoneFile( doneFile: DoneFile, - doneFilePath: string + doneFilePath: string, ): Promise { await fs.writeFile(doneFilePath, JSON.stringify(doneFile, null, 2)); }