跳到主要内容

DOMSnapshot🧪

此领域便于获取包含DOM、布局及样式信息的文档快照。

EN
This domain facilitates obtaining document snapshots with DOM, layout, and style information.

✅️️ Methods

🔨DOMSnapshot.captureSnapshot

返回一个文档快照,其中包含根节点(包括iframe、模板内容和导入文档)的完整DOM树(以扁平化数组形式呈现),以及节点的布局和允许列表内的计算样式信息。返回的DOM树中的Shadow DOM已被扁平化处理。

EN
Returns a document snapshot, including the full DOM tree of the root node (including iframes, template contents, and imported documents) in a flattened array, as well as layout and white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is flattened.
参数必填标记类型描述原文
computedStyles✔️array[string]要返回的计算样式白名单。
ENWhitelist of computed styles to return.
includePaintOrderboolean是否将布局对象的绘制顺序包含到快照中。
ENWhether to include layout object paint orders into the snapshot.
includeDOMRectsboolean是否将DOM矩形(offsetRects、clientRects、scrollRects)包含到快照中
ENWhether to include DOM rectangles (offsetRects, clientRects, scrollRects) into the snapshot
includeBlendedBackgroundColors🧪boolean是否在快照中包含混合背景颜色(默认:false)。混合背景颜色是通过混合与当前元素重叠的所有元素的背景颜色来实现的。
ENWhether to include blended background colors in the snapshot (default: false). Blended background color is achieved by blending background colors of all elements that overlap with the current element.
includeTextColorOpacities🧪boolean是否在快照中包含文本颜色透明度(默认值:false)。元素可能设置了影响其文本颜色的透明度属性。最终文本颜色透明度将根据所有重叠元素的透明度计算得出。
ENWhether to include text color opacity in the snapshot (default: false). An element might have the opacity property set that affects the text color of the element. The final text color opacity is computed based on the opacity of all overlapping elements.
返回对象类型描述原文
documentsarray[DocumentSnapshot]DOM树中的节点。索引0处的DOMNode对应于根文档。
ENThe nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
stringsarray[string]所有字符串属性通过索引引用的共享字符串表。
ENShared string table that all string properties refer to with indexes.

🔨DOMSnapshot.disable

为给定页面禁用DOM快照代理。

EN
Disables DOM snapshot agent for the given page.

🔨DOMSnapshot.enable

为给定页面启用DOM快照代理。

EN
Enables DOM snapshot agent for the given page.

🔨DOMSnapshot.getSnapshot❌️

返回一个文档快照,包括根节点(包含iframe、模板内容和导入文档)的完整DOM树(以扁平化数组形式呈现),以及节点的布局和允许列表内的计算样式信息。返回的DOM树中的Shadow DOM会被扁平化处理。

EN
Returns a document snapshot, including the full DOM tree of the root node (including iframes, template contents, and imported documents) in a flattened array, as well as layout and white-listed computed style information for the nodes. Shadow DOM in the returned DOM tree is flattened.
参数必填标记类型描述原文
computedStyleWhitelist✔️array[string]要返回的计算样式白名单。
ENWhitelist of computed styles to return.
includeEventListenersboolean是否检索DOM监听器的详细信息(默认为false)。
ENWhether or not to retrieve details of DOM listeners (default false).
includePaintOrderboolean是否确定并包含LayoutTreeNodes的绘制顺序索引(默认值为false)。
ENWhether to determine and include the paint order index of LayoutTreeNodes (default false).
includeUserAgentShadowTreeboolean是否在快照中包含用户代理阴影树(默认值为 false)。
ENWhether to include UA shadow tree in the snapshot (default false).
返回对象类型描述原文
domNodesarray[DOMNode]DOM树中的节点。索引0处的DOMNode对应于根文档。
ENThe nodes in the DOM tree. The DOMNode at index 0 corresponds to the root document.
layoutTreeNodesarray[LayoutTreeNode]布局树中的节点。
ENThe nodes in the layout tree.
computedStylesarray[ComputedStyle]布局树中每个节点的白名单计算样式属性。
ENWhitelisted ComputedStyle properties for each node in the layout tree.

✅️️ Types

📌DOMSnapshot.ArrayOfStrings

字符串在字符串表中的索引。

EN
Index of the string in the strings table.

返回类型:array


📌DOMSnapshot.ComputedStyle

根据请求白名单定义的完整计算样式的一个子集。

EN
A subset of the full ComputedStyle as defined by the request whitelist.

返回类型:object

属性必填标记类型描述原文
properties✔️array[NameValue]计算样式属性的名称/值对。
ENName/value pairs of computed style properties.

📌DOMSnapshot.DocumentSnapshot

文档快照。

EN
Document snapshot.

返回类型:object

属性必填标记类型描述原文
documentURL✔️StringIndexDocumentFrameOwner 节点指向的文档 URL。
ENDocument URL that Document or FrameOwner node points to.
title✔️StringIndex文档标题。
ENDocument title.
baseURL✔️StringIndexDocumentFrameOwner 节点用于 URL 补全的基础 URL。
ENBase URL that Document or FrameOwner node uses for URL completion.
contentLanguage✔️StringIndex包含文档的内容语言。
ENContains the document's content language.
encodingName✔️StringIndex包含文档的字符集编码。
ENContains the document's character set encoding.
publicId✔️StringIndexDocumentType 节点的 publicId。
ENDocumentType node's publicId.
systemId✔️StringIndexDocumentType 节点的系统标识符。
ENDocumentType node's systemId.
frameId✔️StringIndex框架所有者元素以及文档节点的框架ID。
ENFrame ID for frame owner elements and also for the document node.
nodes✔️NodeTreeSnapshot一个包含dom节点的表格。
ENA table with dom nodes.
layout✔️LayoutTreeSnapshot布局树中的节点。
ENThe nodes in the layout tree.
textBoxes✔️TextBoxSnapshot布局后的内联文本节点。
ENThe post-layout inline text nodes.
scrollOffsetXnumber水平滚动偏移量。
ENHorizontal scroll offset.
scrollOffsetYnumber垂直滚动偏移量。
ENVertical scroll offset.
contentWidthnumber文档内容宽度。
ENDocument content width.
contentHeightnumber文档内容高度。
ENDocument content height.

📌DOMSnapshot.DOMNode

DOM树中的一个节点。

EN
A Node in the DOM tree.

返回类型:object

属性必填标记类型描述原文
nodeType✔️integerNode的nodeType。
ENNode's nodeType.
nodeName✔️stringNode的nodeName。
ENNode's nodeName.
nodeValue✔️stringNode的nodeValue。
ENNode's nodeValue.
textValuestring仅适用于textarea元素,包含文本值。
ENOnly set for textarea elements, contains the text value.
inputValuestring仅针对输入元素设置,包含输入框关联的文本值。
ENOnly set for input elements, contains the input's associated text value.
inputCheckedboolean仅适用于单选按钮和复选框输入元素,表示该元素是否已被选中
ENOnly set for radio and checkbox input elements, indicates if the element has been checked
optionSelectedboolean仅针对option元素设置,表示该元素是否已被选中
ENOnly set for option elements, indicates if the element has been selected
backendNodeId✔️DOM.BackendNodeIdNode的id,对应于DOM.Node.backendNodeId。
ENNode's id, corresponds to DOM.Node.backendNodeId.
childNodeIndexesarray[integer]节点在getSnapshot返回的domNodes数组中的子节点索引(如果存在)。
ENThe indexes of the node's child nodes in the domNodes array returned by getSnapshot, if any.
attributesarray[NameValue]Element节点的属性。
ENAttributes of an Element node.
pseudoElementIndexesarray[integer]如果存在,与此节点关联的伪元素在getSnapshot返回的domNodes数组中的索引。
ENIndexes of pseudo elements associated with this node in the domNodes array returned by getSnapshot, if any.
layoutNodeIndexinteger节点在getSnapshot返回的layoutTreeNodes数组中的相关布局树节点索引(如果存在)。
ENThe index of the node's related layout tree node in the layoutTreeNodes array returned by getSnapshot, if any.
documentURLstringDocumentFrameOwner 节点指向的文档 URL。
ENDocument URL that Document or FrameOwner node points to.
baseURLstringDocumentFrameOwner 节点用于 URL 完成的 Base URL。
ENBase URL that Document or FrameOwner node uses for URL completion.
contentLanguagestring仅针对文档设置,包含文档的内容语言。
ENOnly set for documents, contains the document's content language.
documentEncodingstring仅针对文档设置,包含文档的字符集编码。
ENOnly set for documents, contains the document's character set encoding.
publicIdstringDocumentType 节点的 publicId。
ENDocumentType node's publicId.
systemIdstringDocumentType 节点的系统标识符。
ENDocumentType node's systemId.
frameIdPage.FrameId框架所有者元素以及文档节点的框架ID。
ENFrame ID for frame owner elements and also for the document node.
contentDocumentIndexintegergetSnapshot 返回的 domNodes 数组中,框架所有者元素的内容文档的索引(如果存在)。
ENThe index of a frame owner element's content document in the domNodes array returned by getSnapshot, if any.
pseudoTypeDOM.PseudoType伪元素节点类型。
ENType of a pseudo element node.
shadowRootTypeDOM.ShadowRootTypeShadow root类型。
ENShadow root type.
isClickableboolean此DOM节点是否响应鼠标点击。这包括通过JavaScript附加了点击事件监听器的节点,以及点击时自然导航的锚点标签。
ENWhether this DOM node responds to mouse clicks. This includes nodes that have had click event listeners attached via JavaScript as well as anchor tags that naturally navigate when clicked.
eventListenersarray[DOMDebugger.EventListener]节点的监听器详情(如果有的话)。
ENDetails of the node's event listeners, if any.
currentSourceURLstring对于具有srcset属性的节点,所选用的URL。
ENThe selected url for nodes with a srcset attribute.
originURLstring生成此节点的脚本(如果有的话)的URL。
ENThe url of the script (if any) that generates this node.
scrollOffsetXnumber滚动偏移量,当此节点为 Document 时设置。
ENScroll offsets, set when this node is a Document.
scrollOffsetYnumber

📌DOMSnapshot.InlineTextBox

已渲染文本位置的布局详情。确切布局不应被视为稳定,可能在版本间发生变化。

EN
Details of post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions.

返回类型:object

属性必填标记类型描述原文
boundingBox✔️DOM.Rect边界框在文档坐标中的位置。注意,文档的滚动偏移量被忽略。
ENThe bounding box in document coordinates. Note that scroll offset of the document is ignored.
startCharacterIndex✔️integer对于此帖子布局文本框子字符串,起始字符索引。在UTF-16中表示为代理对的字符长度为2。
ENThe starting index in characters, for this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
numCharacters✔️integer此帖子布局文本框子字符串中的字符数量。在UTF-16中表示为代理对的字符长度为2。
ENThe number of characters in this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.

📌DOMSnapshot.LayoutTreeNode

DOM树中具有LayoutObject的元素的详细信息。

EN
Details of an element in the DOM tree with a LayoutObject.

返回类型:object

属性必填标记类型描述原文
domNodeIndex✔️integergetSnapshot 返回的 domNodes 数组中相关 DOM 节点的索引。
ENThe index of the related DOM node in the domNodes array returned by getSnapshot.
boundingBox✔️DOM.Rect文档坐标中的边界框。注意,忽略文档的滚动偏移。
ENThe bounding box in document coordinates. Note that scroll offset of the document is ignored.
layoutTextstringLayoutText的内容(如果有的话)。
ENContents of the LayoutText, if any.
inlineTextNodesarray[InlineTextBox]布局后的内联文本节点(如果有的话)。
ENThe post-layout inline text nodes, if any.
styleIndexinteger索引到由 getSnapshot 返回的 computedStyles 数组。
ENIndex into the computedStyles array returned by getSnapshot.
paintOrderinteger全局绘制顺序索引,由节点的堆叠顺序决定。一起绘制的节点将具有相同的索引。仅在getSnapshot中的includePaintOrder为true时提供。
ENGlobal paint order index, which is determined by the stacking order of the nodes. Nodes that are painted together will have the same index. Only provided if includePaintOrder in getSnapshot was true.
isStackingContextboolean设置为 true 表示该元素开启新的层叠上下文。
ENSet to true to indicate the element begins a new stacking context.

📌DOMSnapshot.LayoutTreeSnapshot

包含LayoutObject的DOM树中某个元素的详细信息表。

EN
Table of details of an element in the DOM tree with a LayoutObject.

返回类型:object

属性必填标记类型描述原文
nodeIndex✔️array[integer]captureSnapshot 返回的 NodeTreeSnapshot 数组中对应节点的索引。
ENIndex of the corresponding node in the NodeTreeSnapshot array returned by captureSnapshot.
styles✔️array[ArrayOfStrings]指定计算样式字符串的索引数组,根据传递给 captureSnapshotcomputedStyles 参数进行筛选。
ENArray of indexes specifying computed style strings, filtered according to the computedStyles parameter passed to captureSnapshot.
bounds✔️array[Rectangle]绝对位置边界框。
ENThe absolute position bounding box.
text✔️array[StringIndex]LayoutText的内容(如果有的话)。
ENContents of the LayoutText, if any.
stackingContexts✔️RareBooleanData堆叠上下文信息。
ENStacking context information.
paintOrdersarray[integer]全局绘制顺序索引,由节点的堆叠顺序决定。一起绘制的节点将具有相同的索引。仅在captureSnapshot中的includePaintOrder为true时提供。
ENGlobal paint order index, which is determined by the stacking order of the nodes. Nodes that are painted together will have the same index. Only provided if includePaintOrder in captureSnapshot was true.
offsetRectsarray[Rectangle]节点的偏移矩形。仅在 includeDOMRects 设置为 true 时可用
ENThe offset rect of nodes. Only available when includeDOMRects is set to true
scrollRectsarray[Rectangle]节点的滚动矩形区域。仅在includeDOMRects设置为true时可用
ENThe scroll rect of nodes. Only available when includeDOMRects is set to true
clientRectsarray[Rectangle]节点的客户端矩形。仅在 includeDOMRects 设置为 true 时可用
ENThe client rect of nodes. Only available when includeDOMRects is set to true
blendedBackgroundColors🧪array[StringIndex]与重叠元素颜色混合的背景颜色列表。
ENThe list of background colors that are blended with colors of overlapping elements.
textColorOpacities🧪array[number]计算出的文本不透明度列表。
ENThe list of computed text opacities.

📌DOMSnapshot.NameValue

一个名称/值对。

EN
A name/value pair.

返回类型:object

属性必填标记类型描述原文
name✔️string属性/属性名称。
ENAttribute/property name.
value✔️string属性/属性值。
ENAttribute/property value.

📌DOMSnapshot.NodeTreeSnapshot

包含节点的表格。

EN
Table containing nodes.

返回类型:object

属性必填标记类型描述原文
parentIndexarray[integer]父节点索引。
ENParent node index.
nodeTypearray[integer]Node的nodeType。
ENNode's nodeType.
shadowRootTypeRareStringDataNode 所在阴影根的类型。字符串值等同于 ShadowRootType 枚举。
ENType of the shadow root the Node is in. String values are equal to the ShadowRootType enum.
nodeNamearray[StringIndex]Node的nodeName。
ENNode's nodeName.
nodeValuearray[StringIndex]Node 的 nodeValue。
ENNode's nodeValue.
backendNodeIdarray[DOM.BackendNodeId]Node的id,对应于DOM.Node.backendNodeId。
ENNode's id, corresponds to DOM.Node.backendNodeId.
attributesarray[ArrayOfStrings]Element节点的属性。扁平化的名称、值对。
ENAttributes of an Element node. Flatten name, value pairs.
textValueRareStringData仅适用于textarea元素,包含文本值。
ENOnly set for textarea elements, contains the text value.
inputValueRareStringData仅适用于输入元素,包含输入框的关联文本值。
ENOnly set for input elements, contains the input's associated text value.
inputCheckedRareBooleanData仅针对单选按钮和复选框输入元素设置,表示该元素是否已被选中
ENOnly set for radio and checkbox input elements, indicates if the element has been checked
optionSelectedRareBooleanData仅针对option元素设置,表示该元素是否已被选中
ENOnly set for option elements, indicates if the element has been selected
contentDocumentIndexRareIntegerData快照文档列表中该文档的索引。
ENThe index of the document in the list of the snapshot documents.
pseudoTypeRareStringData伪元素节点类型。
ENType of a pseudo element node.
pseudoIdentifierRareStringData此节点的伪元素标识符。仅当存在有效的伪类型时才会出现。
ENPseudo element identifier for this node. Only present if there is a valid pseudoType.
isClickableRareBooleanData该DOM节点是否响应鼠标点击。这包括通过JavaScript附加了点击事件监听器的节点,以及点击时自然导航的锚点标签。
ENWhether this DOM node responds to mouse clicks. This includes nodes that have had click event listeners attached via JavaScript as well as anchor tags that naturally navigate when clicked.
currentSourceURLRareStringData所选URL用于具有srcset属性的节点。
ENThe selected url for nodes with a srcset attribute.
originURLRareStringData生成此节点的脚本(如果有的话)的URL。
ENThe url of the script (if any) that generates this node.

📌DOMSnapshot.RareBooleanData

返回类型:object

属性必填标记类型描述原文
index✔️array[integer]

📌DOMSnapshot.RareIntegerData

返回类型:object

属性必填标记类型描述原文
index✔️array[integer]
value✔️array[integer]

📌DOMSnapshot.RareStringData

仅存在于少数节点上的数据。

EN
Data that is only present on rare nodes.

返回类型:object

属性必填标记类型描述原文
index✔️array[integer]
value✔️array[StringIndex]

📌DOMSnapshot.Rectangle

返回类型:array


📌DOMSnapshot.StringIndex

字符串在字符串表中的索引。

EN
Index of the string in the strings table.

返回类型:integer


📌DOMSnapshot.TextBoxSnapshot

帖子布局渲染文本位置详情表。确切布局不应被视为稳定,可能在版本间发生变化。

EN
Table of details of the post layout rendered text positions. The exact layout should not be regarded as stable and may change between versions.

返回类型:object

属性必填标记类型描述原文
layoutIndex✔️array[integer]拥有此盒子集合的布局树节点的索引。
ENIndex of the layout tree node that owns this box collection.
bounds✔️array[Rectangle]绝对位置边界框。
ENThe absolute position bounding box.
start✔️array[integer]对于此帖子布局文本框子字符串,起始字符索引。在UTF-16中表示为代理对的字符长度为2。
ENThe starting index in characters, for this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.
length✔️array[integer]此帖子布局文本框子串中的字符数。在UTF-16中表示为代理对的字符长度为2。
ENThe number of characters in this post layout textbox substring. Characters that would be represented as a surrogate pair in UTF-16 have length 2.