Add cdp support for xpath scrapers (#625)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
bnkai
2020-08-04 03:42:40 +03:00
committed by GitHub
parent 1b4a9eed36
commit 4373f9bf01
284 changed files with 133250 additions and 54 deletions

831
vendor/github.com/chromedp/cdproto/css/css.go generated vendored Normal file
View File

@@ -0,0 +1,831 @@
// Package css provides the Chrome DevTools Protocol
// commands, types, and events for the CSS domain.
//
// This domain exposes CSS read/write operations. All CSS objects
// (stylesheets, rules, and styles) have an associated id used in subsequent
// operations on the related object. Each object type has a specific id
// structure, and those are not interchangeable between objects of different
// kinds. CSS objects can be loaded using the get*ForNode() calls (which accept
// a DOM node id). A client can also keep track of stylesheets via the
// styleSheetAdded/styleSheetRemoved events and subsequently load the required
// stylesheet contents using the getStyleSheet[Text]() methods.
//
// Generated by the cdproto-gen command.
package css
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// AddRuleParams inserts a new rule with the given ruleText in a stylesheet
// with given styleSheetId, at the position specified by location.
type AddRuleParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier where a new rule should be inserted.
RuleText string `json:"ruleText"` // The text of a new rule.
Location *SourceRange `json:"location"` // Text position of a new rule in the target style sheet.
}
// AddRule inserts a new rule with the given ruleText in a stylesheet with
// given styleSheetId, at the position specified by location.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-addRule
//
// parameters:
// styleSheetID - The css style sheet identifier where a new rule should be inserted.
// ruleText - The text of a new rule.
// location - Text position of a new rule in the target style sheet.
func AddRule(styleSheetID StyleSheetID, ruleText string, location *SourceRange) *AddRuleParams {
return &AddRuleParams{
StyleSheetID: styleSheetID,
RuleText: ruleText,
Location: location,
}
}
// AddRuleReturns return values.
type AddRuleReturns struct {
Rule *Rule `json:"rule,omitempty"` // The newly created rule.
}
// Do executes CSS.addRule against the provided context.
//
// returns:
// rule - The newly created rule.
func (p *AddRuleParams) Do(ctx context.Context) (rule *Rule, err error) {
// execute
var res AddRuleReturns
err = cdp.Execute(ctx, CommandAddRule, p, &res)
if err != nil {
return nil, err
}
return res.Rule, nil
}
// CollectClassNamesParams returns all class names from specified stylesheet.
type CollectClassNamesParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
}
// CollectClassNames returns all class names from specified stylesheet.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-collectClassNames
//
// parameters:
// styleSheetID
func CollectClassNames(styleSheetID StyleSheetID) *CollectClassNamesParams {
return &CollectClassNamesParams{
StyleSheetID: styleSheetID,
}
}
// CollectClassNamesReturns return values.
type CollectClassNamesReturns struct {
ClassNames []string `json:"classNames,omitempty"` // Class name list.
}
// Do executes CSS.collectClassNames against the provided context.
//
// returns:
// classNames - Class name list.
func (p *CollectClassNamesParams) Do(ctx context.Context) (classNames []string, err error) {
// execute
var res CollectClassNamesReturns
err = cdp.Execute(ctx, CommandCollectClassNames, p, &res)
if err != nil {
return nil, err
}
return res.ClassNames, nil
}
// CreateStyleSheetParams creates a new special "via-inspector" stylesheet in
// the frame with given frameId.
type CreateStyleSheetParams struct {
FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame where "via-inspector" stylesheet should be created.
}
// CreateStyleSheet creates a new special "via-inspector" stylesheet in the
// frame with given frameId.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-createStyleSheet
//
// parameters:
// frameID - Identifier of the frame where "via-inspector" stylesheet should be created.
func CreateStyleSheet(frameID cdp.FrameID) *CreateStyleSheetParams {
return &CreateStyleSheetParams{
FrameID: frameID,
}
}
// CreateStyleSheetReturns return values.
type CreateStyleSheetReturns struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the created "via-inspector" stylesheet.
}
// Do executes CSS.createStyleSheet against the provided context.
//
// returns:
// styleSheetID - Identifier of the created "via-inspector" stylesheet.
func (p *CreateStyleSheetParams) Do(ctx context.Context) (styleSheetID StyleSheetID, err error) {
// execute
var res CreateStyleSheetReturns
err = cdp.Execute(ctx, CommandCreateStyleSheet, p, &res)
if err != nil {
return "", err
}
return res.StyleSheetID, nil
}
// DisableParams disables the CSS agent for the given page.
type DisableParams struct{}
// Disable disables the CSS agent for the given page.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes CSS.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables the CSS agent for the given page. Clients should not
// assume that the CSS agent has been enabled until the result of this command
// is received.
type EnableParams struct{}
// Enable enables the CSS agent for the given page. Clients should not assume
// that the CSS agent has been enabled until the result of this command is
// received.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes CSS.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// ForcePseudoStateParams ensures that the given node will have specified
// pseudo-classes whenever its style is computed by the browser.
type ForcePseudoStateParams struct {
NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the pseudo state.
ForcedPseudoClasses []string `json:"forcedPseudoClasses"` // Element pseudo classes to force when computing the element's style.
}
// ForcePseudoState ensures that the given node will have specified
// pseudo-classes whenever its style is computed by the browser.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-forcePseudoState
//
// parameters:
// nodeID - The element id for which to force the pseudo state.
// forcedPseudoClasses - Element pseudo classes to force when computing the element's style.
func ForcePseudoState(nodeID cdp.NodeID, forcedPseudoClasses []string) *ForcePseudoStateParams {
return &ForcePseudoStateParams{
NodeID: nodeID,
ForcedPseudoClasses: forcedPseudoClasses,
}
}
// Do executes CSS.forcePseudoState against the provided context.
func (p *ForcePseudoStateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandForcePseudoState, p, nil)
}
// GetBackgroundColorsParams [no description].
type GetBackgroundColorsParams struct {
NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get background colors for.
}
// GetBackgroundColors [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getBackgroundColors
//
// parameters:
// nodeID - Id of the node to get background colors for.
func GetBackgroundColors(nodeID cdp.NodeID) *GetBackgroundColorsParams {
return &GetBackgroundColorsParams{
NodeID: nodeID,
}
}
// GetBackgroundColorsReturns return values.
type GetBackgroundColorsReturns struct {
BackgroundColors []string `json:"backgroundColors,omitempty"` // The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load).
ComputedFontSize string `json:"computedFontSize,omitempty"` // The computed font size for this node, as a CSS computed value string (e.g. '12px').
ComputedFontWeight string `json:"computedFontWeight,omitempty"` // The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100').
}
// Do executes CSS.getBackgroundColors against the provided context.
//
// returns:
// backgroundColors - The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load).
// computedFontSize - The computed font size for this node, as a CSS computed value string (e.g. '12px').
// computedFontWeight - The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100').
func (p *GetBackgroundColorsParams) Do(ctx context.Context) (backgroundColors []string, computedFontSize string, computedFontWeight string, err error) {
// execute
var res GetBackgroundColorsReturns
err = cdp.Execute(ctx, CommandGetBackgroundColors, p, &res)
if err != nil {
return nil, "", "", err
}
return res.BackgroundColors, res.ComputedFontSize, res.ComputedFontWeight, nil
}
// GetComputedStyleForNodeParams returns the computed style for a DOM node
// identified by nodeId.
type GetComputedStyleForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetComputedStyleForNode returns the computed style for a DOM node
// identified by nodeId.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getComputedStyleForNode
//
// parameters:
// nodeID
func GetComputedStyleForNode(nodeID cdp.NodeID) *GetComputedStyleForNodeParams {
return &GetComputedStyleForNodeParams{
NodeID: nodeID,
}
}
// GetComputedStyleForNodeReturns return values.
type GetComputedStyleForNodeReturns struct {
ComputedStyle []*ComputedStyleProperty `json:"computedStyle,omitempty"` // Computed style for the specified DOM node.
}
// Do executes CSS.getComputedStyleForNode against the provided context.
//
// returns:
// computedStyle - Computed style for the specified DOM node.
func (p *GetComputedStyleForNodeParams) Do(ctx context.Context) (computedStyle []*ComputedStyleProperty, err error) {
// execute
var res GetComputedStyleForNodeReturns
err = cdp.Execute(ctx, CommandGetComputedStyleForNode, p, &res)
if err != nil {
return nil, err
}
return res.ComputedStyle, nil
}
// GetInlineStylesForNodeParams returns the styles defined inline (explicitly
// in the "style" attribute and implicitly, using DOM attributes) for a DOM node
// identified by nodeId.
type GetInlineStylesForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetInlineStylesForNode returns the styles defined inline (explicitly in
// the "style" attribute and implicitly, using DOM attributes) for a DOM node
// identified by nodeId.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getInlineStylesForNode
//
// parameters:
// nodeID
func GetInlineStylesForNode(nodeID cdp.NodeID) *GetInlineStylesForNodeParams {
return &GetInlineStylesForNodeParams{
NodeID: nodeID,
}
}
// GetInlineStylesForNodeReturns return values.
type GetInlineStylesForNodeReturns struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node.
AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
}
// Do executes CSS.getInlineStylesForNode against the provided context.
//
// returns:
// inlineStyle - Inline style for the specified DOM node.
// attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
func (p *GetInlineStylesForNodeParams) Do(ctx context.Context) (inlineStyle *Style, attributesStyle *Style, err error) {
// execute
var res GetInlineStylesForNodeReturns
err = cdp.Execute(ctx, CommandGetInlineStylesForNode, p, &res)
if err != nil {
return nil, nil, err
}
return res.InlineStyle, res.AttributesStyle, nil
}
// GetMatchedStylesForNodeParams returns requested styles for a DOM node
// identified by nodeId.
type GetMatchedStylesForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetMatchedStylesForNode returns requested styles for a DOM node identified
// by nodeId.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getMatchedStylesForNode
//
// parameters:
// nodeID
func GetMatchedStylesForNode(nodeID cdp.NodeID) *GetMatchedStylesForNodeParams {
return &GetMatchedStylesForNodeParams{
NodeID: nodeID,
}
}
// GetMatchedStylesForNodeReturns return values.
type GetMatchedStylesForNodeReturns struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node.
AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
MatchedCSSRules []*RuleMatch `json:"matchedCSSRules,omitempty"` // CSS rules matching this node, from all applicable stylesheets.
PseudoElements []*PseudoElementMatches `json:"pseudoElements,omitempty"` // Pseudo style matches for this node.
Inherited []*InheritedStyleEntry `json:"inherited,omitempty"` // A chain of inherited styles (from the immediate node parent up to the DOM tree root).
CSSKeyframesRules []*KeyframesRule `json:"cssKeyframesRules,omitempty"` // A list of CSS keyframed animations matching this node.
}
// Do executes CSS.getMatchedStylesForNode against the provided context.
//
// returns:
// inlineStyle - Inline style for the specified DOM node.
// attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
// matchedCSSRules - CSS rules matching this node, from all applicable stylesheets.
// pseudoElements - Pseudo style matches for this node.
// inherited - A chain of inherited styles (from the immediate node parent up to the DOM tree root).
// cssKeyframesRules - A list of CSS keyframed animations matching this node.
func (p *GetMatchedStylesForNodeParams) Do(ctx context.Context) (inlineStyle *Style, attributesStyle *Style, matchedCSSRules []*RuleMatch, pseudoElements []*PseudoElementMatches, inherited []*InheritedStyleEntry, cssKeyframesRules []*KeyframesRule, err error) {
// execute
var res GetMatchedStylesForNodeReturns
err = cdp.Execute(ctx, CommandGetMatchedStylesForNode, p, &res)
if err != nil {
return nil, nil, nil, nil, nil, nil, err
}
return res.InlineStyle, res.AttributesStyle, res.MatchedCSSRules, res.PseudoElements, res.Inherited, res.CSSKeyframesRules, nil
}
// GetMediaQueriesParams returns all media queries parsed by the rendering
// engine.
type GetMediaQueriesParams struct{}
// GetMediaQueries returns all media queries parsed by the rendering engine.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getMediaQueries
func GetMediaQueries() *GetMediaQueriesParams {
return &GetMediaQueriesParams{}
}
// GetMediaQueriesReturns return values.
type GetMediaQueriesReturns struct {
Medias []*Media `json:"medias,omitempty"`
}
// Do executes CSS.getMediaQueries against the provided context.
//
// returns:
// medias
func (p *GetMediaQueriesParams) Do(ctx context.Context) (medias []*Media, err error) {
// execute
var res GetMediaQueriesReturns
err = cdp.Execute(ctx, CommandGetMediaQueries, nil, &res)
if err != nil {
return nil, err
}
return res.Medias, nil
}
// GetPlatformFontsForNodeParams requests information about platform fonts
// which we used to render child TextNodes in the given node.
type GetPlatformFontsForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetPlatformFontsForNode requests information about platform fonts which we
// used to render child TextNodes in the given node.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getPlatformFontsForNode
//
// parameters:
// nodeID
func GetPlatformFontsForNode(nodeID cdp.NodeID) *GetPlatformFontsForNodeParams {
return &GetPlatformFontsForNodeParams{
NodeID: nodeID,
}
}
// GetPlatformFontsForNodeReturns return values.
type GetPlatformFontsForNodeReturns struct {
Fonts []*PlatformFontUsage `json:"fonts,omitempty"` // Usage statistics for every employed platform font.
}
// Do executes CSS.getPlatformFontsForNode against the provided context.
//
// returns:
// fonts - Usage statistics for every employed platform font.
func (p *GetPlatformFontsForNodeParams) Do(ctx context.Context) (fonts []*PlatformFontUsage, err error) {
// execute
var res GetPlatformFontsForNodeReturns
err = cdp.Execute(ctx, CommandGetPlatformFontsForNode, p, &res)
if err != nil {
return nil, err
}
return res.Fonts, nil
}
// GetStyleSheetTextParams returns the current textual content for a
// stylesheet.
type GetStyleSheetTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
}
// GetStyleSheetText returns the current textual content for a stylesheet.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getStyleSheetText
//
// parameters:
// styleSheetID
func GetStyleSheetText(styleSheetID StyleSheetID) *GetStyleSheetTextParams {
return &GetStyleSheetTextParams{
StyleSheetID: styleSheetID,
}
}
// GetStyleSheetTextReturns return values.
type GetStyleSheetTextReturns struct {
Text string `json:"text,omitempty"` // The stylesheet text.
}
// Do executes CSS.getStyleSheetText against the provided context.
//
// returns:
// text - The stylesheet text.
func (p *GetStyleSheetTextParams) Do(ctx context.Context) (text string, err error) {
// execute
var res GetStyleSheetTextReturns
err = cdp.Execute(ctx, CommandGetStyleSheetText, p, &res)
if err != nil {
return "", err
}
return res.Text, nil
}
// SetEffectivePropertyValueForNodeParams find a rule with the given active
// property for the given node and set the new value for this property.
type SetEffectivePropertyValueForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"` // The element id for which to set property.
PropertyName string `json:"propertyName"`
Value string `json:"value"`
}
// SetEffectivePropertyValueForNode find a rule with the given active
// property for the given node and set the new value for this property.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setEffectivePropertyValueForNode
//
// parameters:
// nodeID - The element id for which to set property.
// propertyName
// value
func SetEffectivePropertyValueForNode(nodeID cdp.NodeID, propertyName string, value string) *SetEffectivePropertyValueForNodeParams {
return &SetEffectivePropertyValueForNodeParams{
NodeID: nodeID,
PropertyName: propertyName,
Value: value,
}
}
// Do executes CSS.setEffectivePropertyValueForNode against the provided context.
func (p *SetEffectivePropertyValueForNodeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetEffectivePropertyValueForNode, p, nil)
}
// SetKeyframeKeyParams modifies the keyframe rule key text.
type SetKeyframeKeyParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
KeyText string `json:"keyText"`
}
// SetKeyframeKey modifies the keyframe rule key text.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setKeyframeKey
//
// parameters:
// styleSheetID
// range
// keyText
func SetKeyframeKey(styleSheetID StyleSheetID, rangeVal *SourceRange, keyText string) *SetKeyframeKeyParams {
return &SetKeyframeKeyParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
KeyText: keyText,
}
}
// SetKeyframeKeyReturns return values.
type SetKeyframeKeyReturns struct {
KeyText *Value `json:"keyText,omitempty"` // The resulting key text after modification.
}
// Do executes CSS.setKeyframeKey against the provided context.
//
// returns:
// keyText - The resulting key text after modification.
func (p *SetKeyframeKeyParams) Do(ctx context.Context) (keyText *Value, err error) {
// execute
var res SetKeyframeKeyReturns
err = cdp.Execute(ctx, CommandSetKeyframeKey, p, &res)
if err != nil {
return nil, err
}
return res.KeyText, nil
}
// SetMediaTextParams modifies the rule selector.
type SetMediaTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
Text string `json:"text"`
}
// SetMediaText modifies the rule selector.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setMediaText
//
// parameters:
// styleSheetID
// range
// text
func SetMediaText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetMediaTextParams {
return &SetMediaTextParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
Text: text,
}
}
// SetMediaTextReturns return values.
type SetMediaTextReturns struct {
Media *Media `json:"media,omitempty"` // The resulting CSS media rule after modification.
}
// Do executes CSS.setMediaText against the provided context.
//
// returns:
// media - The resulting CSS media rule after modification.
func (p *SetMediaTextParams) Do(ctx context.Context) (media *Media, err error) {
// execute
var res SetMediaTextReturns
err = cdp.Execute(ctx, CommandSetMediaText, p, &res)
if err != nil {
return nil, err
}
return res.Media, nil
}
// SetRuleSelectorParams modifies the rule selector.
type SetRuleSelectorParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
Selector string `json:"selector"`
}
// SetRuleSelector modifies the rule selector.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setRuleSelector
//
// parameters:
// styleSheetID
// range
// selector
func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams {
return &SetRuleSelectorParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
Selector: selector,
}
}
// SetRuleSelectorReturns return values.
type SetRuleSelectorReturns struct {
SelectorList *SelectorList `json:"selectorList,omitempty"` // The resulting selector list after modification.
}
// Do executes CSS.setRuleSelector against the provided context.
//
// returns:
// selectorList - The resulting selector list after modification.
func (p *SetRuleSelectorParams) Do(ctx context.Context) (selectorList *SelectorList, err error) {
// execute
var res SetRuleSelectorReturns
err = cdp.Execute(ctx, CommandSetRuleSelector, p, &res)
if err != nil {
return nil, err
}
return res.SelectorList, nil
}
// SetStyleSheetTextParams sets the new stylesheet text.
type SetStyleSheetTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Text string `json:"text"`
}
// SetStyleSheetText sets the new stylesheet text.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setStyleSheetText
//
// parameters:
// styleSheetID
// text
func SetStyleSheetText(styleSheetID StyleSheetID, text string) *SetStyleSheetTextParams {
return &SetStyleSheetTextParams{
StyleSheetID: styleSheetID,
Text: text,
}
}
// SetStyleSheetTextReturns return values.
type SetStyleSheetTextReturns struct {
SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any).
}
// Do executes CSS.setStyleSheetText against the provided context.
//
// returns:
// sourceMapURL - URL of source map associated with script (if any).
func (p *SetStyleSheetTextParams) Do(ctx context.Context) (sourceMapURL string, err error) {
// execute
var res SetStyleSheetTextReturns
err = cdp.Execute(ctx, CommandSetStyleSheetText, p, &res)
if err != nil {
return "", err
}
return res.SourceMapURL, nil
}
// SetStyleTextsParams applies specified style edits one after another in the
// given order.
type SetStyleTextsParams struct {
Edits []*StyleDeclarationEdit `json:"edits"`
}
// SetStyleTexts applies specified style edits one after another in the given
// order.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setStyleTexts
//
// parameters:
// edits
func SetStyleTexts(edits []*StyleDeclarationEdit) *SetStyleTextsParams {
return &SetStyleTextsParams{
Edits: edits,
}
}
// SetStyleTextsReturns return values.
type SetStyleTextsReturns struct {
Styles []*Style `json:"styles,omitempty"` // The resulting styles after modification.
}
// Do executes CSS.setStyleTexts against the provided context.
//
// returns:
// styles - The resulting styles after modification.
func (p *SetStyleTextsParams) Do(ctx context.Context) (styles []*Style, err error) {
// execute
var res SetStyleTextsReturns
err = cdp.Execute(ctx, CommandSetStyleTexts, p, &res)
if err != nil {
return nil, err
}
return res.Styles, nil
}
// StartRuleUsageTrackingParams enables the selector recording.
type StartRuleUsageTrackingParams struct{}
// StartRuleUsageTracking enables the selector recording.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-startRuleUsageTracking
func StartRuleUsageTracking() *StartRuleUsageTrackingParams {
return &StartRuleUsageTrackingParams{}
}
// Do executes CSS.startRuleUsageTracking against the provided context.
func (p *StartRuleUsageTrackingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartRuleUsageTracking, nil, nil)
}
// StopRuleUsageTrackingParams stop tracking rule usage and return the list
// of rules that were used since last call to takeCoverageDelta (or since start
// of coverage instrumentation).
type StopRuleUsageTrackingParams struct{}
// StopRuleUsageTracking stop tracking rule usage and return the list of
// rules that were used since last call to takeCoverageDelta (or since start of
// coverage instrumentation).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-stopRuleUsageTracking
func StopRuleUsageTracking() *StopRuleUsageTrackingParams {
return &StopRuleUsageTrackingParams{}
}
// StopRuleUsageTrackingReturns return values.
type StopRuleUsageTrackingReturns struct {
RuleUsage []*RuleUsage `json:"ruleUsage,omitempty"`
}
// Do executes CSS.stopRuleUsageTracking against the provided context.
//
// returns:
// ruleUsage
func (p *StopRuleUsageTrackingParams) Do(ctx context.Context) (ruleUsage []*RuleUsage, err error) {
// execute
var res StopRuleUsageTrackingReturns
err = cdp.Execute(ctx, CommandStopRuleUsageTracking, nil, &res)
if err != nil {
return nil, err
}
return res.RuleUsage, nil
}
// TakeCoverageDeltaParams obtain list of rules that became used since last
// call to this method (or since start of coverage instrumentation).
type TakeCoverageDeltaParams struct{}
// TakeCoverageDelta obtain list of rules that became used since last call to
// this method (or since start of coverage instrumentation).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-takeCoverageDelta
func TakeCoverageDelta() *TakeCoverageDeltaParams {
return &TakeCoverageDeltaParams{}
}
// TakeCoverageDeltaReturns return values.
type TakeCoverageDeltaReturns struct {
Coverage []*RuleUsage `json:"coverage,omitempty"`
Timestamp float64 `json:"timestamp,omitempty"` // Monotonically increasing time, in seconds.
}
// Do executes CSS.takeCoverageDelta against the provided context.
//
// returns:
// coverage
// timestamp - Monotonically increasing time, in seconds.
func (p *TakeCoverageDeltaParams) Do(ctx context.Context) (coverage []*RuleUsage, timestamp float64, err error) {
// execute
var res TakeCoverageDeltaReturns
err = cdp.Execute(ctx, CommandTakeCoverageDelta, nil, &res)
if err != nil {
return nil, 0, err
}
return res.Coverage, res.Timestamp, nil
}
// Command names.
const (
CommandAddRule = "CSS.addRule"
CommandCollectClassNames = "CSS.collectClassNames"
CommandCreateStyleSheet = "CSS.createStyleSheet"
CommandDisable = "CSS.disable"
CommandEnable = "CSS.enable"
CommandForcePseudoState = "CSS.forcePseudoState"
CommandGetBackgroundColors = "CSS.getBackgroundColors"
CommandGetComputedStyleForNode = "CSS.getComputedStyleForNode"
CommandGetInlineStylesForNode = "CSS.getInlineStylesForNode"
CommandGetMatchedStylesForNode = "CSS.getMatchedStylesForNode"
CommandGetMediaQueries = "CSS.getMediaQueries"
CommandGetPlatformFontsForNode = "CSS.getPlatformFontsForNode"
CommandGetStyleSheetText = "CSS.getStyleSheetText"
CommandSetEffectivePropertyValueForNode = "CSS.setEffectivePropertyValueForNode"
CommandSetKeyframeKey = "CSS.setKeyframeKey"
CommandSetMediaText = "CSS.setMediaText"
CommandSetRuleSelector = "CSS.setRuleSelector"
CommandSetStyleSheetText = "CSS.setStyleSheetText"
CommandSetStyleTexts = "CSS.setStyleTexts"
CommandStartRuleUsageTracking = "CSS.startRuleUsageTracking"
CommandStopRuleUsageTracking = "CSS.stopRuleUsageTracking"
CommandTakeCoverageDelta = "CSS.takeCoverageDelta"
)

6214
vendor/github.com/chromedp/cdproto/css/easyjson.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

42
vendor/github.com/chromedp/cdproto/css/events.go generated vendored Normal file
View File

@@ -0,0 +1,42 @@
package css
// Code generated by cdproto-gen. DO NOT EDIT.
// EventFontsUpdated fires whenever a web font is updated. A non-empty font
// parameter indicates a successfully loaded web font.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#event-fontsUpdated
type EventFontsUpdated struct {
Font *FontFace `json:"font,omitempty"` // The web font that has loaded.
}
// EventMediaQueryResultChanged fires whenever a MediaQuery result changes
// (for example, after a browser window has been resized.) The current
// implementation considers only viewport-dependent media features.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#event-mediaQueryResultChanged
type EventMediaQueryResultChanged struct{}
// EventStyleSheetAdded fired whenever an active document stylesheet is
// added.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#event-styleSheetAdded
type EventStyleSheetAdded struct {
Header *StyleSheetHeader `json:"header"` // Added stylesheet metainfo.
}
// EventStyleSheetChanged fired whenever a stylesheet is changed as a result
// of the client operation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#event-styleSheetChanged
type EventStyleSheetChanged struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
}
// EventStyleSheetRemoved fired whenever an active document stylesheet is
// removed.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#event-styleSheetRemoved
type EventStyleSheetRemoved struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // Identifier of the removed stylesheet.
}

348
vendor/github.com/chromedp/cdproto/css/types.go generated vendored Normal file
View File

@@ -0,0 +1,348 @@
package css
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"errors"
"github.com/chromedp/cdproto/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// StyleSheetID [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-StyleSheetId
type StyleSheetID string
// String returns the StyleSheetID as string value.
func (t StyleSheetID) String() string {
return string(t)
}
// StyleSheetOrigin stylesheet type: "injected" for stylesheets injected via
// extension, "user-agent" for user-agent stylesheets, "inspector" for
// stylesheets created by the inspector (i.e. those holding the "via inspector"
// rules), "regular" for regular stylesheets.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-StyleSheetOrigin
type StyleSheetOrigin string
// String returns the StyleSheetOrigin as string value.
func (t StyleSheetOrigin) String() string {
return string(t)
}
// StyleSheetOrigin values.
const (
StyleSheetOriginInjected StyleSheetOrigin = "injected"
StyleSheetOriginUserAgent StyleSheetOrigin = "user-agent"
StyleSheetOriginInspector StyleSheetOrigin = "inspector"
StyleSheetOriginRegular StyleSheetOrigin = "regular"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t StyleSheetOrigin) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t StyleSheetOrigin) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *StyleSheetOrigin) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch StyleSheetOrigin(in.String()) {
case StyleSheetOriginInjected:
*t = StyleSheetOriginInjected
case StyleSheetOriginUserAgent:
*t = StyleSheetOriginUserAgent
case StyleSheetOriginInspector:
*t = StyleSheetOriginInspector
case StyleSheetOriginRegular:
*t = StyleSheetOriginRegular
default:
in.AddError(errors.New("unknown StyleSheetOrigin value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *StyleSheetOrigin) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// PseudoElementMatches CSS rule collection for a single pseudo style.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-PseudoElementMatches
type PseudoElementMatches struct {
PseudoType cdp.PseudoType `json:"pseudoType"` // Pseudo element type.
Matches []*RuleMatch `json:"matches"` // Matches of CSS rules applicable to the pseudo style.
}
// InheritedStyleEntry inherited CSS rule collection from ancestor node.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-InheritedStyleEntry
type InheritedStyleEntry struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // The ancestor node's inline style, if any, in the style inheritance chain.
MatchedCSSRules []*RuleMatch `json:"matchedCSSRules"` // Matches of CSS rules matching the ancestor node in the style inheritance chain.
}
// RuleMatch match data for a CSS rule.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-RuleMatch
type RuleMatch struct {
Rule *Rule `json:"rule"` // CSS rule in the match.
MatchingSelectors []int64 `json:"matchingSelectors"` // Matching selector indices in the rule's selectorList selectors (0-based).
}
// Value data for a simple selector (these are delimited by commas in a
// selector list).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-Value
type Value struct {
Text string `json:"text"` // Value text.
Range *SourceRange `json:"range,omitempty"` // Value range in the underlying resource (if available).
}
// SelectorList selector list data.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-SelectorList
type SelectorList struct {
Selectors []*Value `json:"selectors"` // Selectors in the list.
Text string `json:"text"` // Rule selector text.
}
// StyleSheetHeader CSS stylesheet metainformation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSStyleSheetHeader
type StyleSheetHeader struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The stylesheet identifier.
FrameID cdp.FrameID `json:"frameId"` // Owner frame identifier.
SourceURL string `json:"sourceURL"` // Stylesheet resource URL.
SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with the stylesheet (if any).
Origin StyleSheetOrigin `json:"origin"` // Stylesheet origin.
Title string `json:"title"` // Stylesheet title.
OwnerNode cdp.BackendNodeID `json:"ownerNode,omitempty"` // The backend id for the owner node of the stylesheet.
Disabled bool `json:"disabled"` // Denotes whether the stylesheet is disabled.
HasSourceURL bool `json:"hasSourceURL,omitempty"` // Whether the sourceURL field value comes from the sourceURL comment.
IsInline bool `json:"isInline"` // Whether this stylesheet is created for STYLE tag by parser. This flag is not set for document.written STYLE tags.
StartLine float64 `json:"startLine"` // Line offset of the stylesheet within the resource (zero based).
StartColumn float64 `json:"startColumn"` // Column offset of the stylesheet within the resource (zero based).
Length float64 `json:"length"` // Size of the content (in characters).
EndLine float64 `json:"endLine"` // Line offset of the end of the stylesheet within the resource (zero based).
EndColumn float64 `json:"endColumn"` // Column offset of the end of the stylesheet within the resource (zero based).
}
// Rule CSS rule representation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSRule
type Rule struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
SelectorList *SelectorList `json:"selectorList"` // Rule selector data.
Origin StyleSheetOrigin `json:"origin"` // Parent stylesheet's origin.
Style *Style `json:"style"` // Associated style declaration.
Media []*Media `json:"media,omitempty"` // Media list array (for rules involving media queries). The array enumerates media queries starting with the innermost one, going outwards.
}
// RuleUsage CSS coverage information.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-RuleUsage
type RuleUsage struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
StartOffset float64 `json:"startOffset"` // Offset of the start of the rule (including selector) from the beginning of the stylesheet.
EndOffset float64 `json:"endOffset"` // Offset of the end of the rule body from the beginning of the stylesheet.
Used bool `json:"used"` // Indicates whether the rule was actually used by some element in the page.
}
// SourceRange text range within a resource. All numbers are zero-based.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-SourceRange
type SourceRange struct {
StartLine int64 `json:"startLine"` // Start line of range.
StartColumn int64 `json:"startColumn"` // Start column of range (inclusive).
EndLine int64 `json:"endLine"` // End line of range
EndColumn int64 `json:"endColumn"` // End column of range (exclusive).
}
// ShorthandEntry [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-ShorthandEntry
type ShorthandEntry struct {
Name string `json:"name"` // Shorthand name.
Value string `json:"value"` // Shorthand value.
Important bool `json:"important,omitempty"` // Whether the property has "!important" annotation (implies false if absent).
}
// ComputedStyleProperty [no description].
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSComputedStyleProperty
type ComputedStyleProperty struct {
Name string `json:"name"` // Computed style property name.
Value string `json:"value"` // Computed style property value.
}
// Style CSS style representation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSStyle
type Style struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
CSSProperties []*Property `json:"cssProperties"` // CSS properties in the style.
ShorthandEntries []*ShorthandEntry `json:"shorthandEntries"` // Computed values for all shorthands found in the style.
CSSText string `json:"cssText,omitempty"` // Style declaration text (if available).
Range *SourceRange `json:"range,omitempty"` // Style declaration range in the enclosing stylesheet (if available).
}
// Property CSS property declaration data.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSProperty
type Property struct {
Name string `json:"name"` // The property name.
Value string `json:"value"` // The property value.
Important bool `json:"important,omitempty"` // Whether the property has "!important" annotation (implies false if absent).
Implicit bool `json:"implicit,omitempty"` // Whether the property is implicit (implies false if absent).
Text string `json:"text,omitempty"` // The full property text as specified in the style.
ParsedOk bool `json:"parsedOk,omitempty"` // Whether the property is understood by the browser (implies true if absent).
Disabled bool `json:"disabled,omitempty"` // Whether the property is disabled by the user (present for source-based properties only).
Range *SourceRange `json:"range,omitempty"` // The entire property range in the enclosing style declaration (if available).
}
// Media CSS media rule descriptor.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSMedia
type Media struct {
Text string `json:"text"` // Media query text.
Source MediaSource `json:"source"` // Source of the media query: "mediaRule" if specified by a @media rule, "importRule" if specified by an @import rule, "linkedSheet" if specified by a "media" attribute in a linked stylesheet's LINK tag, "inlineSheet" if specified by a "media" attribute in an inline stylesheet's STYLE tag.
SourceURL string `json:"sourceURL,omitempty"` // URL of the document containing the media query description.
Range *SourceRange `json:"range,omitempty"` // The associated rule (@media or @import) header range in the enclosing stylesheet (if available).
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the stylesheet containing this object (if exists).
MediaList []*MediaQuery `json:"mediaList,omitempty"` // Array of media queries.
}
// MediaQuery media query descriptor.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-MediaQuery
type MediaQuery struct {
Expressions []*MediaQueryExpression `json:"expressions"` // Array of media query expressions.
Active bool `json:"active"` // Whether the media query condition is satisfied.
}
// MediaQueryExpression media query expression descriptor.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-MediaQueryExpression
type MediaQueryExpression struct {
Value float64 `json:"value"` // Media query expression value.
Unit string `json:"unit"` // Media query expression units.
Feature string `json:"feature"` // Media query expression feature.
ValueRange *SourceRange `json:"valueRange,omitempty"` // The associated range of the value text in the enclosing stylesheet (if available).
ComputedLength float64 `json:"computedLength,omitempty"` // Computed length of media query expression (if applicable).
}
// PlatformFontUsage information about amount of glyphs that were rendered
// with given font.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-PlatformFontUsage
type PlatformFontUsage struct {
FamilyName string `json:"familyName"` // Font's family name reported by platform.
IsCustomFont bool `json:"isCustomFont"` // Indicates if the font was downloaded or resolved locally.
GlyphCount float64 `json:"glyphCount"` // Amount of glyphs that were rendered with this font.
}
// FontFace properties of a web font:
// https://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#font-descriptions.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-FontFace
type FontFace struct {
FontFamily string `json:"fontFamily"` // The font-family.
FontStyle string `json:"fontStyle"` // The font-style.
FontVariant string `json:"fontVariant"` // The font-variant.
FontWeight string `json:"fontWeight"` // The font-weight.
FontStretch string `json:"fontStretch"` // The font-stretch.
UnicodeRange string `json:"unicodeRange"` // The unicode-range.
Src string `json:"src"` // The src.
PlatformFontFamily string `json:"platformFontFamily"` // The resolved platform font family
}
// KeyframesRule CSS keyframes rule representation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSKeyframesRule
type KeyframesRule struct {
AnimationName *Value `json:"animationName"` // Animation name.
Keyframes []*KeyframeRule `json:"keyframes"` // List of keyframes.
}
// KeyframeRule CSS keyframe rule representation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSKeyframeRule
type KeyframeRule struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // The css style sheet identifier (absent for user agent stylesheet and user-specified stylesheet rules) this rule came from.
Origin StyleSheetOrigin `json:"origin"` // Parent stylesheet's origin.
KeyText *Value `json:"keyText"` // Associated key text.
Style *Style `json:"style"` // Associated style declaration.
}
// StyleDeclarationEdit a descriptor of operation to mutate style declaration
// text.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-StyleDeclarationEdit
type StyleDeclarationEdit struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier.
Range *SourceRange `json:"range"` // The range of the style text in the enclosing stylesheet.
Text string `json:"text"` // New style text.
}
// MediaSource source of the media query: "mediaRule" if specified by a
// @media rule, "importRule" if specified by an @import rule, "linkedSheet" if
// specified by a "media" attribute in a linked stylesheet's LINK tag,
// "inlineSheet" if specified by a "media" attribute in an inline stylesheet's
// STYLE tag.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#type-CSSMedia
type MediaSource string
// String returns the MediaSource as string value.
func (t MediaSource) String() string {
return string(t)
}
// MediaSource values.
const (
MediaSourceMediaRule MediaSource = "mediaRule"
MediaSourceImportRule MediaSource = "importRule"
MediaSourceLinkedSheet MediaSource = "linkedSheet"
MediaSourceInlineSheet MediaSource = "inlineSheet"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t MediaSource) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t MediaSource) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *MediaSource) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch MediaSource(in.String()) {
case MediaSourceMediaRule:
*t = MediaSourceMediaRule
case MediaSourceImportRule:
*t = MediaSourceImportRule
case MediaSourceLinkedSheet:
*t = MediaSourceLinkedSheet
case MediaSourceInlineSheet:
*t = MediaSourceInlineSheet
default:
in.AddError(errors.New("unknown MediaSource value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *MediaSource) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}