UNPKG

browse

Version:

Unified Browserbase CLI for browser automation and cloud APIs.

25 lines (24 loc) 900 B
import { Args } from "@oclif/core"; import { BrowseCommand } from "../base.js"; import { driverCommandFlags, runDriverCommandFromFlags, } from "../lib/driver/command-cli.js"; export default class Eval extends BrowseCommand { static description = "Evaluate JavaScript in the active browser page."; static examples = [ "browse eval 'document.title'", "browse eval 'document.querySelector(\"h1\")?.textContent'", "browse eval 'window.location.href' --session research", ]; static args = { expression: Args.string({ description: "JavaScript expression to evaluate.", required: true, }), }; static flags = { ...driverCommandFlags, }; async run() { const { args, flags } = await this.parse(Eval); await runDriverCommandFromFlags("eval", { expression: args.expression }, flags); } }