lino-levan / astral

A high-level puppeteer/playwright-like library for Deno
https://jsr.io/@astral/astral
MIT License
253 stars 17 forks source link

How to change to dark mode? #79

Closed oscarotero closed 4 months ago

oscarotero commented 4 months ago

Hi! I'd like to use this library to create screenshots of webpages in light and dark mode. Is there any way to specify the prefers-color-scheme option? It would be nice to have a function like page.setPreferrerColorScheme("dark").

lino-levan commented 4 months ago

Try

await page.emulateMediaFeatures([{ name: "prefers-color-scheme", value: "dark" }]);

Let me know if that works for you :). I was waiting for someone to ask for this.

oscarotero commented 4 months ago

It works like a champ! thanks for the fast implementation!