When you want to take chat widgets, there are annoying chat widgets that you would love to hide. It is easy to do.
How to hide chat widgets when taking a screenshot with Puppeteer
When you want to take chat widgets, there are annoying chat widgets that you would love to hide. It is easy to do.
All you need is to detect the selector of the chat container and then apply display: none !important
to it.
Let’s look, for example, with Crisp chat on ScreenshotOne main page:
To hide it, find the selector of the main container of the chat. You can do it by using Chrome DevTools:
And then add the hiding styling before taking a screenshot:
const puppeteer = require('puppeteer');
(async () => { const browser = await puppeteer.launch({ headless: true }); try { const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 1024 });
await page.goto('https://screenshotone.com/', { waitUntil: ['load', 'domcontentloaded', 'networkidle0'] });
await page.addStyleTag({ content: '.crisp-client { display: none !important; }', });
await page.screenshot({ type: 'png', path: 'screenshot.png' }); } catch (e) { console.log(e) } finally { await browser.close(); }})();
And voila:
If you take screenshots at scale, you need to do this for every chat widget. Or you can use [ScreenshotOne API] that knows how to hide Facebook Messenger, Tawk, Crisp, Intercom, Drift, and many more.
Have a nice day 👋 and you also might find helpful:
Interviews, tips, guides, industry best practices, and news.
Check out how ScreenshotOne relies on Cloudflare Workers as an API gateway to enhance performance, reliability, and cost-efficiency.
There 3 simple ways to render website screenshots in Next.js—using Puppeteer, Cloudflare Browser Rendering, and a screenshot API like ScreenshotOne or similar.
The article examines how you can take screenshots of any URL with Java by using Selenium, Puppeteer alternatives, Playwright, or screenshot API as a service.
Exhaustive documentation, ready SDKs, no-code tools, and other automation to help you render website screenshots and outsource all the boring work related to that to us.