chromedevtools

package
v0.0.0-...-fe67f73 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DisableContextMenuScript = `
	document.addEventListener('contextmenu', event => event.preventDefault());
`

DisableContextMenuScript is a browser-side script that disables Chrome's right-click context menu

View Source
const DisableShortcutsScript = `` /* 1674-byte string literal not displayed */

DisableShortcutsScript disables default shortcuts

Variables

This section is empty.

Functions

This section is empty.

Types

type Bounds

type Bounds struct {
	Left        int         `json:"left"`
	Top         int         `json:"top"`
	Width       int         `json:"width"`
	Height      int         `json:"height"`
	WindowState WindowState `json:"windowState"`
}

Bounds defines settable window properties.

type Chrome

type Chrome struct {
	sync.Mutex
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

Chrome represents a chrome process

func NewChromeWithArgs

func NewChromeWithArgs(chromeBinary string, args ...string) (*Chrome, error)

NewChromeWithArgs starts chrome process with arguments

func (*Chrome) AddScriptToEvaluateOnNewDocument

func (c *Chrome) AddScriptToEvaluateOnNewDocument(script string) error

AddScriptToEvaluateOnNewDocument adds JavaScript code to be evaluated when new document is evaluted

func (*Chrome) Back

func (c *Chrome) Back() error

Back navigates to previous page in browser history

func (*Chrome) Bind

func (c *Chrome) Bind(name string, f bindingFunc) error

Bind creates a browser-side binding with name to a function

func (*Chrome) Bounds

func (c *Chrome) Bounds() (Bounds, error)

Bounds returns the size, position and a state of a browser window

func (*Chrome) DisableContextMenu

func (c *Chrome) DisableContextMenu() error

DisableContextMenu disables Chrome's default context menu on right mouse click

func (*Chrome) DisableDefaultShortcuts

func (c *Chrome) DisableDefaultShortcuts() error

DisableDefaultShortcuts disables default shortucts like Ctr-N to open a new tab

func (*Chrome) Eval

func (c *Chrome) Eval(expr string) (json.RawMessage, error)

Eval evaluates JavaScript expression in the browser and returns response

func (*Chrome) Forward

func (c *Chrome) Forward() error

Forward navigates to next page in browser history

func (*Chrome) GetNavigationHistory

func (c *Chrome) GetNavigationHistory() (*NavigationHistory, error)

GetNavigationHistory returns browser navigation history

func (*Chrome) Kill

func (c *Chrome) Kill() error

Kill kills the chrome process

func (*Chrome) Load

func (c *Chrome) Load(url string) error

Load navigates to a given URL

func (*Chrome) PDF

func (c *Chrome) PDF(width, height int) ([]byte, error)

PDF generates a PDF of a given size and returns the PDF content as []byte

func (*Chrome) PNG

func (c *Chrome) PNG(x, y, width, height int, bg uint32, scale float32) ([]byte, error)

PNG generates

func (*Chrome) Reload

func (c *Chrome) Reload(disableCache bool) error

Reload reloads current page https://pptr.dev/#?product=Puppeteer&show=api-pagereloadoptions

func (*Chrome) Send

func (c *Chrome) Send(method string, params h) (json.RawMessage, error)

Send sends a method with a parameters to the browser, waits for response and returns response as json

func (*Chrome) SetBounds

func (c *Chrome) SetBounds(b Bounds) error

SetBounds sets the size, position and state of a browser window

type NavigationHistory struct {
	CurrentIndex int                       `json:"currentIndex"`
	Entries      []*NavigationHistoryEntry `json:"entries"`
}

NavigationHistory represents browser navigation history

type NavigationHistoryEntry struct {
	ID             int64  `json:"id"`
	URL            string `json:"url"`
	UserTypedURL   string `json:"userTypedURL"`
	Title          string `json:"title"`
	TransitionType string `json:"transitionType"`
}

NavigationHistoryEntry represents a single entry in navigation history

type WindowState

type WindowState string

WindowState defines the state of the Chrome window, possible values are "normal", "maximized", "minimized" and "fullscreen".

const (
	// WindowStateNormal defines a normal state of the browser window
	WindowStateNormal WindowState = "normal"
	// WindowStateMaximized defines a maximized state of the browser window
	WindowStateMaximized WindowState = "maximized"
	// WindowStateMinimized defines a minimized state of the browser window
	WindowStateMinimized WindowState = "minimized"
	// WindowStateFullscreen defines a fullscreen state of the browser window
	WindowStateFullscreen WindowState = "fullscreen"
)

Jump to

Keyboard shortcuts

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