How to access shadow-root (user-agent) from context of a chrome extension?

216 views Asked by At

I've looked at chrome.dom.openOrClosedShadowRoot API (Ref: https://developer.chrome.com/docs/extensions/reference/dom/#method-openOrClosedShadowRoot) but that does not seem to work on shadow-root (user-agent). These shadow-root's seem to be browser's implementation for elements such as input, video, etc.

I tried accessing element.shadowRoot and chrome.dom.openOrClosedShadowRoot(element) and was expecting to receive the shadowRoot object, but it always returns null for shadow-root(user-agent).

1

There are 1 answers

0
wOxxOm On

The only method is to use chrome.debugger API in an extension script like the popup or the background script to send DOM.getNodeForLocation with includeUserAgentShadowDOM parameter.

Note that using the debugger API will show a warning over all tabs in Chrome.