Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CyberFoxar opened this issue Apr 4, 2023 · 2 comments

Comments

@CyberFoxar
Copy link

CyberFoxar commented Apr 4, 2023

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.

@CyberFoxar CyberFoxar changed the title Allow userStyles (and userscripts?) to pierce trough shadow dom elements [FireMonkey][Feature-Request] Allow userStyles (and userscripts?) to pierce trough shadow dom elements Apr 4, 2023
@erosman
Copy link
Owner

erosman commented Apr 8, 2023

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
Copy link
Owner

erosman commented Jul 17, 2023

See also

  • https://github.com/violentmonkey/violentmonkey/issues/1852

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants