erosman / support

Support Location for all my extensions
Mozilla Public License 2.0
174 stars 12 forks source link

[FireMonkey][Feature-Request] Allow userStyles (and userscripts?) to pierce trough shadow dom elements #547

Open CyberFoxar opened 1 year ago

CyberFoxar commented 1 year ago

Feature Request: Pierce Shadow-dom

Shadow-dom is being used more and more with webcomponents. It's nifty, it isolates styles and more. The issue is that shadow dom isolates its own styles, and thus ignore a globally-injected stylesheet (and scripts). This makes us unable to re-style nested components inside a shadow dom easily.

It has been an issue for a while with userscripts managers, but it can be solved, this would be a nifty thing to have.

A potential way of doing that would be to check if there are any shadow-dom and inject/replace the stylesheet with ours, but I believe there are more efficients way of doing that. Injecting arbitrary javascript is trickier, and might lead to unintended side-effect, so it might be better to either provide utility functions or leave it to userscripts developpers.

erosman commented 1 year ago

As mentioned in FireMonkey Help: addElement, userscripts should be able to inject JavaScript (no GM API), DOM, & CSS into shadow DOM if it is open i.e. {mode: "open"}.

// appending to shadowRoot
const elem = GM_addElement(parentElement.shadowRoot, 'iframe', {src: 'https://....'});

See also

erosman commented 1 year ago

See also