Custom CSS & JavaScript Injection
Inject custom CSS rules and JavaScript code to modify any webpage before capturing. Hide elements, change colors, add branding, or execute custom logic.
Custom CSS Injection
The css parameter allows you to inject any valid CSS rules into the page before the screenshot is taken. This is perfect for hiding unwanted elements, changing colors, or customizing the appearance.
Your CSS is injected after all page styles load, giving your rules the highest specificity. Use !important if needed to override stubborn styles.
API Parameter
css={url-encoded CSS}
Pass your CSS rules as a URL-encoded string. The CSS will be injected into a <style> tag on the page.
CSS Example: Hide Header & Footer
/* Original CSS */
header, footer, .popup-modal {
display: none !important;
}
/* URL encoded in API call */
https://api.rasterwise.com/v1/get-screenshot
?apikey=YOUR_API_KEY
&url=https://example.com
&css=header%2C%20footer%2C%20...
JavaScript Example: Click Button & Wait
// Original JavaScript
document.querySelector('.accept-cookies').click();
document.querySelector('.expand-all').click();
// URL encoded in API call
https://api.rasterwise.com/v1/get-screenshot
?apikey=YOUR_API_KEY
&url=https://example.com
&js=document.querySelector...
&delay=2000
JavaScript Injection
The js parameter lets you execute custom JavaScript on the page before capture. This enables dynamic interactions like clicking buttons, expanding accordions, or modifying content.
Combine with the delay parameter to give your script time to execute and the page time to update before the screenshot is taken.
API Parameter
js={url-encoded JavaScript}
Pass your JavaScript as a URL-encoded string. The script executes in the page context with full DOM access.
Common Use Cases
Custom CSS and JavaScript enable powerful screenshot customization
Hide Sensitive Data
Use CSS to hide email addresses, phone numbers, or other sensitive information from screenshots.
Custom Branding
Change colors, fonts, or add watermarks to screenshots for consistent branding across reports.
Trigger Interactions
Use JavaScript to click buttons, expand menus, or close modals before capturing the page.
Dismiss Cookie Banners
Automatically click "Accept" buttons on cookie consent dialogs with JavaScript injection.
Remove Distractions
Hide navigation bars, sidebars, ads, or any other elements that distract from the main content.
Modify Content
Use JavaScript to change text, update numbers, or populate forms before taking the screenshot.
Combine with Other Features
CSS and JavaScript injection work seamlessly with other capabilities
Full Page Screenshots
Hide sticky headers with CSS before capturing long scrolling pages.
Element Targeting
Style specific elements before capturing them in isolation.
Viewport Control
Use responsive CSS media queries with custom viewport sizes.
Webhooks
Receive modified screenshots via webhook for automated processing.
Ready to Customize Your Screenshots?
Get started with GetScreenshot's CSS and JavaScript injection. Available on all plans.