app

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type         string            `json:"type"`
	Name         string            `json:"name,omitempty"`
	Value        any               `json:"value,omitempty"`
	Search       string            `json:"search,omitempty"`
	Replace      string            `json:"replace,omitempty"`
	ReplaceAll   bool              `json:"replaceAll,omitempty"`
	StatusCode   int               `json:"statusCode,omitempty"`
	Headers      map[string]string `json:"headers,omitempty"`
	Body         string            `json:"body,omitempty"`
	BodyEncoding string            `json:"bodyEncoding,omitempty"`
	Encoding     string            `json:"encoding,omitempty"`
	Patches      []JSONPatch       `json:"patches,omitempty"`
}

func (*Action) UnmarshalJSON

func (a *Action) UnmarshalJSON(data []byte) error

type App

type App struct {
	// contains filtered or unexported fields
}

func New

func New(opts Options) *App

func (*App) Run

func (a *App) Run(ctx context.Context) error

func (*App) Shutdown

func (a *App) Shutdown()

type Browser

type Browser struct {
	// contains filtered or unexported fields
}

func NewBrowser

func NewBrowser(launch bool, port int) *Browser

func (*Browser) IsLaunched

func (b *Browser) IsLaunched() bool

func (*Browser) Start

func (b *Browser) Start(ctx context.Context, browserType string, args []string, url string) error

func (*Browser) Stop

func (b *Browser) Stop() error

type CDP

type CDP struct {
	// contains filtered or unexported fields
}

func NewCDP

func NewCDP(host string, port int, timeout int, verbose bool) *CDP

func (*CDP) AttachToTarget

func (c *CDP) AttachToTarget(ctx context.Context, targetID string) error

func (*CDP) Close

func (c *CDP) Close() error

func (*CDP) CloseBrowser

func (c *CDP) CloseBrowser() error

func (*CDP) Connect

func (c *CDP) Connect(ctx context.Context) error

func (*CDP) DisableFetch

func (c *CDP) DisableFetch(ctx context.Context) error

func (*CDP) EnableFetch

func (c *CDP) EnableFetch(ctx context.Context) (fetch.RequestPausedClient, error)

func (*CDP) EnableNetwork

func (c *CDP) EnableNetwork(ctx context.Context) error

func (*CDP) ListTargets

func (c *CDP) ListTargets(ctx context.Context) ([]CDPTarget, error)

func (*CDP) NavigateTo

func (c *CDP) NavigateTo(ctx context.Context, targetURL string) error

func (*CDP) NewTab

func (c *CDP) NewTab(ctx context.Context, targetURL string) (*CDPTarget, error)

func (*CDP) TargetClient

func (c *CDP) TargetClient() *cdp.Client

type CDPTarget

type CDPTarget struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	URL   string `json:"url"`
	Type  string `json:"type"`
}

type Condition

type Condition struct {
	Type    string   `json:"type"`
	Name    string   `json:"name,omitempty"`
	Value   string   `json:"value,omitempty"`
	Values  []string `json:"values,omitempty"`
	Pattern string   `json:"pattern,omitempty"`
	Path    string   `json:"path,omitempty"`
}

func (*Condition) UnmarshalJSON

func (c *Condition) UnmarshalJSON(data []byte) error

type Config

type Config struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Version     string         `json:"version"`
	Description string         `json:"description,omitempty"`
	Settings    map[string]any `json:"settings,omitempty"`
	Rules       []Rule         `json:"rules"`
}

func LoadConfig

func LoadConfig(configFile string, configData []byte) (*Config, error)

type Intercept

type Intercept struct {
	// contains filtered or unexported fields
}

func NewIntercept

func NewIntercept(cdp *CDP, config *Config) *Intercept

func (*Intercept) Start

func (i *Intercept) Start(ctx context.Context) error

type JSONPatch

type JSONPatch struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	From  string `json:"from,omitempty"`
	Value any    `json:"value,omitempty"`
}

type Match

type Match struct {
	AllOf []Condition `json:"allOf,omitempty"`
	AnyOf []Condition `json:"anyOf,omitempty"`
}

type Options

type Options struct {
	Host          string
	Port          int
	Launch        bool
	LaunchBrowser string
	LaunchArgs    []string
	URL           string
	ConfigFile    string
	ConfigData    []byte
	ListTargets   bool
	Target        string
	Verbose       bool
	Timeout       int
}

type Rule

type Rule struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Enabled  bool     `json:"enabled"`
	Priority int      `json:"priority"`
	Stage    string   `json:"stage"`
	Match    Match    `json:"match"`
	Actions  []Action `json:"actions"`
}

type Target

type Target struct {
	// contains filtered or unexported fields
}

func NewTarget

func NewTarget(cdp *CDP) *Target

func (*Target) Select

func (t *Target) Select(ctx context.Context, targetID string, url string) (*CDPTarget, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL