Documentation
¶
Overview ¶
browser.go
launch_chromedriver.go
launch_direct.go
patcher.go
patcher_binary.go
patcher_fetch.go
patcher_platform.go
stealth.go
Index ¶
- Variables
- func ChromeMajorVersion(path string) (int, error)
- func ChromeVersion(path string) (string, error)
- func DeleteFlags() []string
- func FindChrome() (string, error)
- func Stealth(page *rod.Page) error
- func StealthFlags() map[string]string
- func StealthScripts() []string
- type Browser
- type Config
- type MemoryStats
- type Patcher
- type Xvfb
Constants ¶
This section is empty.
Variables ¶
var ErrCDCNotFound = errors.New("cdc pattern not found in chromedriver binary")
ErrCDCNotFound is returned when the ChromeDriver binary does not contain the cdc_ automation marker. The binary may be already patched or from an unsupported ChromeDriver version.
Functions ¶
func ChromeMajorVersion ¶
ChromeMajorVersion returns the major version number of Chrome at the given path.
func ChromeVersion ¶
ChromeVersion returns the full version string (e.g., "120.0.6099.109").
func DeleteFlags ¶
func DeleteFlags() []string
DeleteFlags returns Chrome flags that should be removed from launch arguments to avoid detection (typically added by automation libraries).
func FindChrome ¶
FindChrome locates a Chrome or Chromium executable on the system.
func Stealth ¶
Stealth injects anti-detection scripts into a rod page. Call before navigating. Scripts persist across navigations.
func StealthFlags ¶
StealthFlags returns Chrome command-line flags for stealth operation. Keys are flag names, values are flag values (empty string for boolean flags).
func StealthScripts ¶
func StealthScripts() []string
StealthScripts returns JavaScript snippets to inject via CDP Page.addScriptToEvaluateOnNewDocument for bot detection evasion.
Types ¶
type Browser ¶ added in v1.0.2
Browser wraps a rod.Browser with the underlying Chrome process, providing safe cleanup via Browser.Close.
func New ¶
New launches a stealth-configured Chrome and connects go-rod to it. Set [Config.PatchChromeDriver] or [Config.ChromeDriverPath] to launch through a patched ChromeDriver instead of directly.
func (*Browser) BrowserMemory ¶ added in v1.0.4
func (b *Browser) BrowserMemory() (MemoryStats, error)
BrowserMemory returns the aggregated RSS and VMS for the browser's entire process tree (root process + all descendants). Returns an error if the browser process is not running.
func (*Browser) Close ¶ added in v1.0.2
Close shuts down the browser, kills Chrome, and removes temporary files. Safe to call multiple times.
func (*Browser) Minimal ¶ added in v1.0.4
Minimal sets up page-level request hijacking that blocks visual/resource-heavy CDP types (Stylesheet, Image, Font, Media, Manifest, TextTrack, Prefetch, Ping). Call before navigating. For browsers launched with [Config.Minimal], this is applied automatically to the default page; call it manually for additional pages.
type Config ¶
type Config struct {
ChromePath string // Path to Chrome executable. Auto-detected if empty.
Headless bool // Run in headless mode. Default true unless VirtualDisplay is enabled.
VirtualDisplay bool // Use Xvfb virtual display. Implies Headless=false. Default false. Tested on Linux only.
UserDataDir string // Custom user data directory. Auto-created if empty.
ExtraArgs []string // Additional command-line arguments to pass to Chrome.
WindowWidth int // Initial window width. Default 1920.
WindowHeight int // Initial window height. Default 1080.
Language string // Browser language (Accept-Language). Default "en-US".
ConnectTimeout time.Duration // Timeout for connecting to Chrome. Default 15s.
NoSandbox bool // Add --no-sandbox flag. Required in some environments (e.g. root on Linux).
ChromeDriverPath string // Path to ChromeDriver executable. If set, will launch through ChromeDriver instead of directly.
PatchChromeDriver bool // Whether to patch ChromeDriver for stealth. Only applies if ChromeDriverPath is not set. Default false.
Minimal bool // Block visual/resource-heavy requests (CSS, images, fonts, media, etc.) browser-wide. Default false.
BlockFilenames []string // Optional list of filenames to block regardless of type (e.g. "analytics.js"). Case-insensitive.
}
Config controls the behavior of the undetected browser.
type MemoryStats ¶ added in v1.0.4
type MemoryStats struct {
RSS uint64 // Resident Set Size in bytes (sum of entire process tree).
VMS uint64 // Virtual Memory Size in bytes (sum of entire process tree).
}
MemoryStats holds aggregated memory information for the browser process tree.
type Patcher ¶
type Patcher struct {
MajorVersion int
DriverPath string
DataDir string
// MaxDownloadSize is the maximum permitted archive size in bytes.
// Default: 100 MB.
MaxDownloadSize int64
// ExpectedSHA256 optionally pins the download to a specific hash.
// When non-empty, Run verifies the downloaded archive matches this
// hex-encoded SHA256 digest.
ExpectedSHA256 string
// DownloadSHA256 is populated after Run with the hex-encoded SHA256
// of the downloaded archive. Can be used for auditing or pinning.
DownloadSHA256 string
// contains filtered or unexported fields
}
Patcher downloads and patches a ChromeDriver binary to remove automation detection markers injected by ChromeDriver into the browser.
func NewPatcher ¶
NewPatcher creates a patcher for the given Chrome major version.