From 380b2378e821fbe26011a0ae7cb3ebc6dbdcf018 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 24 Feb 2025 22:34:01 +0200 Subject: Fix tasks after website changes --- src/tiktok_task.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/tiktok_task.ts') diff --git a/src/tiktok_task.ts b/src/tiktok_task.ts index 7e85c5c..15e30e0 100644 --- a/src/tiktok_task.ts +++ b/src/tiktok_task.ts @@ -46,8 +46,26 @@ export const runDownloadTiktokTask = async (task: TikTokTask) => { } } + try { + const cont = await page.waitForSelector("button.continue-web", { + timeout: 3000, + }); + if (cont) { + console.log( + "Looks like a 'continue using the web' dialog, clicking continue", + ); + await cont.click(); + } + } catch (e) { + if (e instanceof TimeoutError) { + console.log("No 'continue using the web' dialog found"); + } else { + throw e; + } + } + await page.type("input#url", task.url); - await page.click("button[type=submit]"); + await page.click('button[type="submit"]'); console.log("Waiting for a bit"); await wait(1000); @@ -83,7 +101,7 @@ export const runDownloadTiktokTask = async (task: TikTokTask) => { const downloadButton = await page.waitForSelector( "a[data-event=server01_file]", - { timeout: 10_000 } + { timeout: 10_000 }, ); if (!downloadButton) { throw new Error("Could not find download button"); -- cgit v1.3