From ea804a2cd7751af2a5b18869bd4da368dc15f0d2 Mon Sep 17 00:00:00 2001 From: tsingliu <410869548@qq.com> Date: Sun, 8 Feb 2026 13:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=93=E5=BC=80=E7=BD=91?= =?UTF-8?q?=E9=A1=B5=E5=90=8E=E7=9A=84=E7=AD=89=E5=BE=85=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tools/screenshot.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tools/screenshot.ts b/src/tools/screenshot.ts index 61b5c52..d359045 100644 --- a/src/tools/screenshot.ts +++ b/src/tools/screenshot.ts @@ -98,6 +98,10 @@ export const ScreenshotTool: ToolModule = { fullPage: { type: "boolean", description: "If true (default), takes a screenshot of the full scrollable page. Set to false for viewport only." + }, + waitTime: { + type: "number", + description: "Optional delay in seconds to wait for page resources to load before capturing (default: 1)." } }, required: ["url", "outputPath"] @@ -162,8 +166,12 @@ export const ScreenshotTool: ToolModule = { // Wait for fonts to be ready await page.evaluate(() => document.fonts.ready); - // Additional small delay for dynamic content and font rendering - await page.waitForTimeout(1000); + // Additional delay for dynamic content (user specified or default 1s) + const waitTimeMs = (args.waitTime || 1) * 1000; + if (waitTimeMs > 0) { + console.log(`Waiting for ${waitTimeMs}ms...`); + await page.waitForTimeout(waitTimeMs); + } await page.screenshot({ path: args.outputPath,