Browser Extensions
Augment your browser sessions with your own Chrome extensions.
For applications requiring enhanced functional capabilities, providing your own Chrome extension is a great option. With Browserbase, using extensions is easy.
Upload an extension
First, for the simplest example, refer to
Upload an Extension API
and execute the curl
command. You should receive a response containing the extension’s id
.
Make sure to save that extensionId
as you’ll need it to use when creating your
session.
A more complete example is below:
Create and upload a custom extension
This Python script zips up a very simple Chrome extension, uploads it, and then
stores the resulting extensionId
in a text file for subsequent use in your session.
For this example, your Chrome extension will be a ZIP archive containing these two files,
manifest.json
and content-script.js
:
You must upload a valid Chrome extension in a .zip
file format containing a
manifest.json
at the root.
The file path to the extension should point to the zipped file. Do not unpack it. This file must be smaller than 4.5 MB.
In this script, the extension files are compressed into an in-memory ZIP archive. This is then uploaded to the Extensions API endpoint.
The extension’s new id
is printed out and also stored in a text file, which can
then be used to enable the extension on a per-session basis.
Create a session using the extension
Once you’re ready to use your uploaded Chrome extension, create a new session and load the extension into the browser.
Create a new session using the Sessions API endpoint.
To enable the extension, make sure to include your projectId
and extensionId
parameters
in the request payload.
Starting a new session with an extension can increase the session creation time. The browser must be restarted to load the extension, which itself has nonzero load time.
Verify the extension is loaded and working
Then, verify that the extension is working correctly. This is done by checking for a specific change or behavior that your extension introduces. In this example, the page title should have been modified by the test extension.
Was this page helpful?