Social BrowserProfiles, KI & Automatisierung

User Scripts SDK

Automate the current tab with SOCIALBROWSER.page

Use trusted User Scripts for selectors, waits, forms, extraction, mouse, keyboard and page helpers.

Docs: Updated 11 Sep 2026Scope: Social Browser developer integration

Trusted User Scripts

Use SOCIALBROWSER.page inside the current tab

Trusted Social Browser User Scripts receive the global SOCIALBROWSER object. SOCIALBROWSER.page gives you JavaScript-only, Puppeteer-inspired helpers for the exact tab where the script is running. You do not need a separate Node.js process for this path.

const page = SOCIALBROWSER.page; const email = await page.waitForSelector("#email", { visible: true, timeout: 10000, }); if (!email) return null; await page.type("#email", "name@example.com", { clear: true }); await page.type("#password", "placeholder-password", { clear: true }); await page.click('button[type="submit"]'); return await page.waitForSelector(".dashboard, .login-error", { visible: true, timeout: 15000, });
AreaCommon helpersUse
Page actionsclick, dblclick, rightClick, hover, focusInteract with elements.
Inputtype, setValue, clear, selectOption, checkForms and editable controls.
WaitingwaitForSelector, waitForFunction, waitForTimeout, waitForGoneSynchronize with page state.
Querying$, $$, $eval, $$eval, findDeepFind and read DOM content.
Scrollingscroll, scrollTo, scrollToElement, scrollHumanMove the viewport.
Devicesmouse, keyboard, touchscreen, cursorLower-level input control.
Locatorlocator(...)Keep a target together across wait/fill/focus/click steps.

Reliability

Lifecycle and target-selection rules

Resolve targets late

Find the intended target immediately before use instead of caching a runtime target for a long time.

Re-resolve after restart

A restart/reconnect can create new runtime IDs even when the persistent Profile is the same.

Verify before acting

Check URL/title/Profile context before sending an action in a multi-Profile session.

Expect navigation changes

Navigation can rebuild a renderer/CDP frame. Your code should wait for the new page state instead of assuming the old frame remains valid.

async function findTargetPage(browser, expectedUrlPrefix) { const pages = await browser.pages(); const page = pages.find(p => p.url().startsWith(expectedUrlPrefix)); if (!page) throw new Error("Target is not available"); return page; } let page = await findTargetPage(browser, "https://example.com/"); await page.goto("https://example.com/dashboard"); // Resolve/validate again when your workflow crosses a restart or reconnect boundary. page = await findTargetPage(browser, "https://example.com/");

Errors

Handle failures explicitly

The JavaScript page helpers are designed to fail safely for unavailable targets/actions and commonly resolve to null. Guard important results. The real Puppeteer bridge can also return structured automation errors such as invalid requests, unavailable bridge state, or a missing matching page.

const saveButton = await SOCIALBROWSER.page.click("#save"); if (!saveButton) { console.warn("Save button was not available"); return null; }
ConditionRecommended response
Endpoint does not answerConfirm Social Browser is running and API/debugging access is enabled in API Clients.
No matching targetRefresh the live target list; do not reuse an old runtime ID.
Selector returns no elementWait for the expected page state, use a stronger selector, and guard a null result.
Navigation replaces the rendererWait for navigation/page readiness and resolve the page again when necessary.
Puppeteer method unsupportedUse a supported helper/Electron path or another CDP method available in the installed build.

Security

Developer access is powerful — scope it carefully

  • Keep the debugging/API endpoint bound to 127.0.0.1 unless you intentionally secure another network path.
  • Do not publish API keys, client secrets or remote debugging endpoints in source control.
  • Treat trusted User Scripts as privileged code; review them before enabling them.
  • Use Profile-level separation so automation for one account/workspace does not accidentally act in another.
  • Do not expose internal runtime IDs as durable database identifiers.
  • Use these capabilities only on systems, pages and accounts you are authorized to operate.

Complete examples

Practical workflow patterns

Read a dashboard value

const page = SOCIALBROWSER.page; const dashboard = await page.waitForSelector(".dashboard", { visible: true, timeout: 15000, }); if (!dashboard) return null; return await page.$eval("[data-balance]", node => node.textContent.trim() );

Wait for a loader, then collect rows

const page = SOCIALBROWSER.page; await page.waitForGone(".loading-overlay", { timeout: 20000 }); return (await page.$$eval("table tbody tr", rows => rows.map(row => Array.from(row.cells, cell => cell.textContent.trim())) )) || [];

External QA check through Puppeteer

const puppeteer = require("puppeteer-core"); const browser = await puppeteer.connect({ browserURL: "http://127.0.0.1:60101", defaultViewport: null, }); try { const page = (await browser.pages()).find(p => p.url().includes("example.com") ); if (!page) throw new Error("Expected page is not open"); const result = { title: await page.title(), url: page.url(), hasMain: await page.$("main") !== null, }; console.log(result); } finally { await browser.disconnect(); }