Script Context
When script() is called, you receive a context object (IScriptContext) that contains everything you need.
async script(context) {
// context.browser — Puppeteer Browser
// context.page — Puppeteer Page
// context.profile — Anti-detect profile info
// context.index — Profile index (0-based)
// context.globalInput — Global input values
// context.profileInput — Per-profile input values
// context.output — Output values (pre-populated from previous runs)
// context.logger — Logger instance
// context.browserUtils — BrowserUtils instance (v1.0.19+)
}browser — Browser Instance
The Puppeteer Browser object. You rarely use this directly — use BrowserUtils instead.
Example 1 — Get all open pages
const pages = await context.browser.pages()
context.logger.info(`Open tabs: ${pages.length}`)Example 2 — Access browser version
const version = await context.browser.version()
context.logger.info(`Browser: ${version}`)page — Page Instance
The main Puppeteer Page for this profile.
Example 1 — Get current URL
const currentUrl = context.page.url()
context.logger.info(`Current page: ${currentUrl}`)Example 2 — Execute JavaScript in browser
const title = await context.page.evaluate(() => document.title)
await browser.writeOutput('pageTitle', title)profile — Anti-detect Profile
Information about the current anti-detect browser profile (IAntidetectProfile).
| Field | Type | Description |
|---|---|---|
id | string | Unique profile ID |
name | string | Human-readable name |
provider | 'gpm' | 'hidemium' | 'genlogin' | Anti-detect provider |
raw_proxy | string? | Proxy string |
browser_type | 'chromium' | 'firefox' | Browser engine |
browser_version | string | Browser version |
profile_path | string | Local data path |
note | string | User note |
created_at | string | ISO 8601 creation date |
Example 1 — Log profile info
context.logger.info(`Running: ${context.profile.name} (${context.profile.provider})`)
context.logger.info(`Proxy: ${context.profile.raw_proxy ?? 'None'}`)Example 2 — Conditional logic by provider
if (context.profile.provider === 'gpm') {
// GPM-specific logic
} else if (context.profile.provider === 'hidemium') {
// Hidemium-specific logic
}index — Profile Index
Zero-based index of the current profile in the execution queue.
Example 1 — Log progress
context.logger.info(`Processing profile ${context.index + 1}`)Example 2 — Skip first profile for warm-up
if (context.index === 0) {
context.logger.info('First profile — running setup...')
}globalInput — Global Input Values
Values shared across all profiles, typed from your config.
Example 1 — Access global URL
const { targetUrl, maxRetries } = context.globalInput
await browser.goto(targetUrl)Example 2 — Use select input
const { mode } = context.globalInput
if (mode === 'fast') {
// skip optional steps
} else {
// full flow with all checks
}profileInput — Per-Profile Input Values
Values specific to each profile, typed from your config.
Example 1 — Login credentials
const { email, password } = context.profileInput
await browser.type('#email', email)
await browser.type('#password', password)Example 2 — Optional field with fallback
const proxy = context.profileInput.proxy || 'no-proxy'
context.logger.info(`Using proxy: ${proxy}`)output — Output Values
Pre-populated output values from previous runs. Updated in real-time when you call writeOutput().
Example 1 — Skip if already completed
if (context.output.loginStatus === 'Success') {
context.logger.info('Already logged in from previous run, skipping')
return
}Example 2 — Resume from previous state
const previousStep = context.output.lastStep
if (previousStep === 'registered') {
// skip registration, go to verification
await browser.goto('/verify')
} else {
await browser.goto('/register')
}logger — Logger Instance
Direct access to the logger for custom messages.
Example 1 — Different log levels
context.logger.info('Starting process...')
context.logger.warn('Slow response detected')
context.logger.error('Login failed!')
context.logger.success('All done!')
context.logger.debug('Debug: element found')Example 2 — Structured logging
context.logger.info(`Profile: ${context.profile.name} started`)
context.logger.success(`Login completed for ${context.profile.name}`)browserUtils — BrowserUtils Instance
Added in v1.0.19
Direct access to the BrowserUtils instance — no need to create one manually.
[!NOTE] In
beforeBrowserOpened(), onlybrowserUtils.writeOutput()is available. Other methods (click, type, goto, etc.) throw an error because the browser isn’t open yet. Inscript()andafterBrowserClosed(), all methods work normally.
Example 1 — Use directly from context
async script(context) {
const { browserUtils, logger } = context;
await browserUtils.goto('https://example.com');
await browserUtils.click('#login');
await browserUtils.writeOutput('status', 'Done');
}Example 2 — Write output in beforeBrowserOpened hook
protected async beforeBrowserOpened(context) {
const { browserUtils, profile } = context;
// writeOutput works even before browser opens
await browserUtils.writeOutput('hookOrder', 'beforeBrowserOpened');
if (profile.name.includes('skip')) return false;
}