Documentation
¶
Index ¶
- func GetStealthLaunchFlags() []string
- type Browser
- func (b *Browser) ActivePage() *rod.Page
- func (b *Browser) ClearAndType(ctx context.Context, elementIndex int, text string, elementMap *dom.ElementMap) error
- func (b *Browser) Click(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
- func (b *Browser) ClickAt(ctx context.Context, x, y float64) error
- func (b *Browser) Close() error
- func (b *Browser) CloseTab(tabID string) error
- func (b *Browser) DoubleClick(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
- func (b *Browser) EvaluateJS(ctx context.Context, script string) (string, error)
- func (b *Browser) ExtractContent(ctx context.Context) (string, error)
- func (b *Browser) Focus(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
- func (b *Browser) GetElementMap(ctx context.Context) (*dom.ElementMap, error)
- func (b *Browser) GetTitle() string
- func (b *Browser) GetURL() string
- func (b *Browser) GoBack(ctx context.Context) error
- func (b *Browser) GoForward(ctx context.Context) error
- func (b *Browser) Hover(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
- func (b *Browser) IsPageReady() bool
- func (b *Browser) ListTabs() []TabInfo
- func (b *Browser) Navigate(ctx context.Context, url string) error
- func (b *Browser) NewTab(ctx context.Context, url string) (string, error)
- func (b *Browser) Reload(ctx context.Context) error
- func (b *Browser) Screenshot(ctx context.Context, fullPage bool) ([]byte, error)
- func (b *Browser) ScreenshotAfterAction(ctx context.Context) ([]byte, error)
- func (b *Browser) ScreenshotAfterActionWithAnnotations(ctx context.Context, elementMap *dom.ElementMap) ([]byte, error)
- func (b *Browser) ScreenshotSafe(ctx context.Context, fullPage bool) ([]byte, error)
- func (b *Browser) ScreenshotSafeWithAnnotations(ctx context.Context, elementMap *dom.ElementMap) ([]byte, error)
- func (b *Browser) ScreenshotWithAnnotations(ctx context.Context, elementMap *dom.ElementMap, fullPage bool) ([]byte, error)
- func (b *Browser) Scroll(ctx context.Context, direction string, amount float64, elementIndex *int, ...) error
- func (b *Browser) ScrollToElement(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
- func (b *Browser) SendKeys(ctx context.Context, keys string) error
- func (b *Browser) SetMaxElements(max int)
- func (b *Browser) Start(ctx context.Context) error
- func (b *Browser) SwitchTab(tabID string) error
- func (b *Browser) TypeText(ctx context.Context, elementIndex int, text string, elementMap *dom.ElementMap) error
- func (b *Browser) WaitForPageReady(ctx context.Context, timeout time.Duration) error
- func (b *Browser) WaitStable(ctx context.Context) error
- type Config
- type ElementMapAdapter
- type StealthConfig
- type TabInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStealthLaunchFlags ¶
func GetStealthLaunchFlags() []string
GetStealthLaunchFlags returns Chrome flags for stealth mode.
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser wraps rod.Browser with enhanced functionality.
func (*Browser) ActivePage ¶
ActivePage returns the currently active page.
func (*Browser) ClearAndType ¶
func (b *Browser) ClearAndType(ctx context.Context, elementIndex int, text string, elementMap *dom.ElementMap) error
ClearAndType clears an input and types new text.
func (*Browser) DoubleClick ¶
func (b *Browser) DoubleClick(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
DoubleClick double-clicks on an element by index.
func (*Browser) EvaluateJS ¶
EvaluateJS evaluates JavaScript code on the page.
func (*Browser) ExtractContent ¶
ExtractContent extracts text content from the page.
func (*Browser) GetElementMap ¶
GetElementMap extracts interactive elements from the current page.
func (*Browser) IsPageReady ¶
IsPageReady checks if the current page is ready for screenshot capture.
func (*Browser) Screenshot ¶
Screenshot takes a screenshot of the current page. Uses the enhanced screenshot package with proper page readiness checks.
func (*Browser) ScreenshotAfterAction ¶
ScreenshotAfterAction captures a screenshot after an action completes. Waits for page stability before capturing.
func (*Browser) ScreenshotAfterActionWithAnnotations ¶
func (b *Browser) ScreenshotAfterActionWithAnnotations(ctx context.Context, elementMap *dom.ElementMap) ([]byte, error)
ScreenshotAfterActionWithAnnotations captures an annotated screenshot after an action.
func (*Browser) ScreenshotSafe ¶
ScreenshotSafe takes a screenshot, returning nil (not error) for blank pages. This is useful for agent loops where blank screenshots should be skipped.
func (*Browser) ScreenshotSafeWithAnnotations ¶
func (b *Browser) ScreenshotSafeWithAnnotations(ctx context.Context, elementMap *dom.ElementMap) ([]byte, error)
ScreenshotSafeWithAnnotations takes an annotated screenshot, returning nil for blank pages.
func (*Browser) ScreenshotWithAnnotations ¶
func (b *Browser) ScreenshotWithAnnotations(ctx context.Context, elementMap *dom.ElementMap, fullPage bool) ([]byte, error)
ScreenshotWithAnnotations takes a screenshot with element annotations. This is the main entry point for annotated screenshots.
func (*Browser) Scroll ¶
func (b *Browser) Scroll(ctx context.Context, direction string, amount float64, elementIndex *int, elementMap *dom.ElementMap) error
Scroll scrolls the page or an element.
func (*Browser) ScrollToElement ¶
func (b *Browser) ScrollToElement(ctx context.Context, elementIndex int, elementMap *dom.ElementMap) error
ScrollToElement scrolls an element into view.
func (*Browser) SetMaxElements ¶
SetMaxElements sets the maximum number of elements to extract.
func (*Browser) TypeText ¶
func (b *Browser) TypeText(ctx context.Context, elementIndex int, text string, elementMap *dom.ElementMap) error
TypeText types text into an element by index.
func (*Browser) WaitForPageReady ¶
WaitForPageReady waits until the page is ready, with timeout.
type Config ¶
type Config struct {
// Headless runs the browser without a visible window.
Headless bool
// ProfileDir is the directory for browser profiles.
ProfileDir string
// ProfileName is the name of the profile to use.
// Empty string uses a temporary profile.
ProfileName string
// Viewport is the browser viewport size.
ViewportWidth int
ViewportHeight int
// ShowHighlight shows visual feedback for actions.
ShowHighlight bool
// HighlightDuration is how long to show highlights.
HighlightDuration time.Duration
// Debug enables verbose logging.
Debug bool
// ShowAnnotations enables element annotations on screenshots.
// When true, screenshots include bounding boxes and index labels.
ShowAnnotations bool
// Stealth configures anti-detection measures.
Stealth StealthConfig
}
Config holds browser configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a default browser configuration.
type ElementMapAdapter ¶
type ElementMapAdapter struct {
// contains filtered or unexported fields
}
ElementMapAdapter adapts dom.ElementMap to screenshot.ElementMapInterface.
func NewElementMapAdapter ¶
func NewElementMapAdapter(em *dom.ElementMap) *ElementMapAdapter
NewElementMapAdapter creates an adapter for annotation.
func (*ElementMapAdapter) GetElements ¶
func (a *ElementMapAdapter) GetElements() []screenshotpkg.ElementInfo
GetElements returns elements as screenshot.ElementInfo slice.
func (*ElementMapAdapter) Len ¶
func (a *ElementMapAdapter) Len() int
Len returns the number of elements.
type StealthConfig ¶
type StealthConfig struct {
// EnableStealth enables stealth mode with anti-detection.
EnableStealth bool
// UserAgent overrides the browser user agent.
UserAgent string
// Locale sets the browser locale (e.g., "en-US").
Locale string
// Timezone sets the browser timezone (e.g., "America/New_York").
Timezone string
// WebGLVendor spoofs the WebGL vendor.
WebGLVendor string
// WebGLRenderer spoofs the WebGL renderer.
WebGLRenderer string
// HumanLikeDelays adds random delays between actions.
HumanLikeDelays bool
// MinDelay minimum delay between actions (ms).
MinDelay int
// MaxDelay maximum delay between actions (ms).
MaxDelay int
}
StealthConfig configures anti-detection measures.
func DefaultStealthConfig ¶
func DefaultStealthConfig() StealthConfig
DefaultStealthConfig returns sensible stealth defaults.