As with most things in JavaScript, there's a workaround to access the elements on a "closed" shadow DOM: hijacking the attachShadow method:

Element.prototype._attachShadow = Element.prototype.attachShadow;
Element.prototype.attachShadow = function () {
    return this._attachShadow( { mode: "open" } );
};

This forces mode to be "open" every time, giving you access to any shadow DOM created after the code runs.

Previous on JavaScript
Mastodon Mastodon