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
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 10m33s
This commit is contained in:
parent
1b7251fbcb
commit
0999474fbd
8 changed files with 176 additions and 17 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue