Custom Injection
Inject custom CSS or JavaScript into the page before the screenshot is taken.
Use custom_css to override styles (hide elements, change fonts, force colours) and custom_js to run arbitrary JavaScript (close modals, scroll, manipulate the DOM). Both are applied before capture. Maximum 10 000 characters each.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
custom_css | string | optional | CSS injected into the page before capture. Max 10 000 characters. |
custom_js | string | optional | JavaScript executed before capture. Max 10 000 characters. |
Code Examples
# Force dark background via CSS injection
curl -X POST "https://screenshotcore.com/api/v1/screenshot" \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","custom_css":"body{background:#111!important;color:#eee!important}"}' \
-o dark.png
# Remove a modal via JS before capture
curl -X POST "https://screenshotcore.com/api/v1/screenshot" \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","custom_js":"document.querySelector(\".modal\")?.remove()"}' \
-o clean.pngResponse
(Raw PNG bytes with custom CSS/JS applied, Content-Type: image/png)