你正在訪問的內容是外部程式的映像位址,僅用於使用者加速訪問,本站無法保證其可靠性。當前的連結位址(單點即可複製)為 https://greasyfork.org.cn/zh-CN/scripts/541149-inject-stylus-into-shadowroots,源站連結 點此以跳轉

Inject Stylus into shadowRoots

inject styles of stylus-addon in shadowRoot



點此查看下載連結位址https://update.greasyfork.org.cn/scripts/541149/Inject%20Stylus%20into%20shadowRoots.user.js

安装此脚本?
作者
hdyzen
日安装量
0
总安装量
12
评分
1 0 0
版本
2.2
创建于
2025-06-29
更新于
2025-10-18
大小
2.6 KB
许可证
GPL-3.0-only
适用于
所有网站

Inject Stylus in Shadow DOM

Userscript that automatically injects styles from Stylus (and other userstyle managers) into any shadowRoot.
This allows you to customize web components and encapsulated elements that normally would not inherit your styles.


  • Supports:
    • Stylus
    • Stylish
    • xStyle
    • User JavaScript and CSS
    • Amino Live Editor
    • Stylebot
    • Magic CSS
    • Custom CSS by Denis

Styling inside a shadowRoot

The key selector is :host.
It refers to the shadow host element of the shadowRoot, letting you apply styles only inside the shadow boundary.

/* Apply to all elements on the page */
* {
  border: 1px solid violet;
}

/* Apply only to elements inside the shadowRoot */
:host * {
  border: 1px solid mediumpurple;
}

/* Apply styles only if the host has a specific class */
:host(.dark-theme) {
  border: 1px solid blue;
}

Useful variations

  • :host() — conditionally apply styles when the host matches a selector.
  • :host-context() — apply styles based on the host’s external context (not supported in Firefox)

Installation

  1. Install a userscript manager such as Violentmonkey
  2. Install the script on GreasyFork
  3. Create or edit your styles with Stylus or another supported extension

License

GPL-3.0-only