User Preferences

BrowserCat allows you to set specialized user preferences for your browser instance at launch time. This feature is similar to tweaking Chrome’s “about://flags” or Firefox’s “about:config”.

These settings can be used to enable experimental features, tweak browser behavior, or enable/disable specific features.

Available options

User preferences are set using the userPrefs key within the BrowserCat-Opts header. This key should be an object with key-value pairs representing the preferences you want to set.

interface BrowserCatOptsHeader {
  // An object of user preferences to set.
  // Keys are case-sensitive.
  userPrefs?: Record<string, string | number | boolean>
}

At present, only Chrome, Chromium, and Firefox support setting user preferences. Webkit does not.

You’ll find a searchable list of settings by entering “about://flags” or “about:config” into your URL bar. But you may find the following resources useful:

Configure user prefs

Send your user prefs using the BrowserCat-Opts header. Here’s a sample configuration:

const headers = {
  'browsercat-opts': JSON.stringify({
    userPrefs: {
      DigitalGoodsApi: true,
      IsolateOrigins: true,
      passwordEchoDurationInSeconds: 10,
    },
  }),
};
headers = {
    'browsercat-opts': json.dumps({
        'userPrefs': {
            'DigitalGoodsApi': True,
            'IsolateOrigins': True,
            'passwordEchoDurationInSeconds': 10,
        },
    })
}

Playwright request

Let’s use our proxy config in a Playwright request:

import * as pw from 'playwright';

const bcatUrl = 'wss://api.browsercat.com/connect';
const browser = await pw.chromium.connect(bcatUrl, {
  headers: {
    'api-key': '<YOUR_API_KEY>',
    'browsercat-opts': JSON.stringify({
      userPrefs: {
        DigitalGoodsApi: true,
        IsolateOrigins: true,
        passwordEchoDurationInSeconds: 10,
      },
    }),
  },
});
await browser.close();
import asyncio
from playwright.async_api import async_playwright, Playwright

bcatUrl = 'wss://api.browsercat.com/connect'

async def run():
    async with async_playwright() as pw:
        browser = await pw.chromium.connect(bcatUrl, headers={
            'Api-Key': '<YOUR_API_KEY>'
            'browsercat-opts': json.dumps({
                'userPrefs': {
                    'DigitalGoodsApi': True,
                    'IsolateOrigins': True,
                    'passwordEchoDurationInSeconds': 10,
                },
            })
        })
        await browser.close()

asyncio.get_event_loop().run_until_complete(run())

Puppeteer request

Let’s see our headers in a Puppeteer request:

import puppeteer from 'puppeteer-core';

const bcatUrl = 'wss://api.browsercat.com/connect';
const browser = await puppeteer.connect({
  browserWSEndpoint: bcatUrl,
  headers: {
    'api-key': '<YOUR_API_KEY>',
    'browsercat-opts': JSON.stringify({
      userPrefs: {
        DigitalGoodsApi: true,
        IsolateOrigins: true,
        passwordEchoDurationInSeconds: 10,
      },
    }),
  },
});
await browser.close();
import asyncio
from pyppeteer import connect

bcatUrl = 'wss://api.browsercat.com/connect'

async def run():
    browser = await connect({
        'browserWSEndpoint': bcatUrl,
        'headers': {
            'api-key': '<YOUR_API_KEY>',
            'browsercat-opts': json.dumps({
                'userPrefs': {
                    'DigitalGoodsApi': True,
                    'IsolateOrigins': True,
                    'passwordEchoDurationInSeconds': 10,
                },
            })
        }
    })
    await browser.close()

asyncio.get_event_loop().run_until_complete(run())