Browser JavaScript injection

Inject an external JavaScript URL before the screenshot.

Host a script at your own URL, reference it with script_url, and the browser executes it against the rendered page before capture — ideal for larger, reusable scripts. For a short snippet passed directly in the request, run inline JavaScript instead.

  • Use your hosted script
  • Rendered DOM access
  • Capture final state
pre-capture script
google.js
const input = document.querySelector(
  'input[name=q]'
);
input.value = 'Car Rental';
input.form.submit();
execute
Rendered pageSearch results ready
Script completed before capture
Practical uses

Reach the state that a static URL cannot.

The script runs after the browser renders the page and before Add Screenshots creates the image.

Populate forms

Fill search boxes, login fields, filters, and other inputs.

Dismiss overlays

Close consent banners, dialogs, and other obstructive UI.

Trigger widgets

Open tabs, accordions, menus, and application states.

Chain workflows

Combine scripts with click, wait, scroll, and storage options.

Three-step setup

Host, reference, and capture.

Keep the script at a URL accessible to the capture browser and reference it with script_url.

  1. 01
    Host the JavaScript

    Publish the file from your CDN, object storage, or another public HTTPS URL.

  2. 02
    Add script_url

    Include the encoded script location in a Screenshot API request or request template.

  3. 03
    Capture the final state

    The browser executes the script, settles the page, and produces the screenshot.

Working example

Submit the script URL with the capture request.

This example enters "Car Rental" into Google search and submits the form before capture.

Screenshot requestGET
https://api.addscreenshots.com/screenshots
?apikey=YOUR_API_KEY
&script_url=https://example.com/google.js
&url=https://google.com
google.jsJavaScript
const input = document.querySelector('input[name=q]');
input.value = 'Car Rental';
input.form.submit();
Captured state

The screenshot contains the scripted result.

The hosted script has populated and submitted the search before the image is captured.

Google Car Rental results captured after JavaScript injection
Build the workflow

Automate interactive screenshots with your own script.

Create the API key, host the script, and reuse the same request in schedules or templates.

Explore plans