feat: add css parameter for custom CSS injection in screenshots
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 10m33s

This commit is contained in:
OpenClaw 2026-03-04 21:06:50 +01:00
parent 1b7251fbcb
commit 0999474fbd
8 changed files with 176 additions and 17 deletions

View file

@ -16,6 +16,7 @@ export interface ScreenshotOptions {
waitUntil?: "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
darkMode?: boolean;
hideSelectors?: string[];
css?: string;
}
export interface ScreenshotResult {
@ -60,6 +61,10 @@ export async function takeScreenshot(opts: ScreenshotOptions): Promise<Screensho
await new Promise(r => setTimeout(r, Math.min(opts.delay!, 5000)));
}
if (opts.css) {
await page.addStyleTag({ content: opts.css });
}
if (opts.hideSelectors && opts.hideSelectors.length > 0) {
await page.addStyleTag({
content: opts.hideSelectors.map(s => s + ' { display: none !important }').join('\n')