Greasy Fork is available in English.

Inject stylus in Shadow DOM

inject stylus to shadowRoot

作者
hdyzen
日安装量
0
总安装量
12
评分
1 0 0
版本
0.1.2b
创建于
2024-02-07
更新于
2024-02-28
许可证
MIT
适用于

Add styles of stylus addon in shadowRoot

⚠️Warning - Use this on sites like sh.reddit.com that has hundreds of shadowRoots, may cause some performance issues


Modify the match metadata for the site you want to execute the inject or add through the script manager in the script tab, example for match:

// @match           https:/www.reddit.com/*
// @match           https:/www.wikipedia.com/*
// @match           https:/www.anothersite.com/*
// @match           https:/greasyfork.org/*

To apply styles only to elements within shadowRoot use the :host pseudo-class, example:

:host [selector] {
  border: 1px solid red;
}
:host * {
  border: 1px solid blue;
}

Version [0.1.1a] supports live updating, no longer need to reload the page to apply the changes

The script monkey patches attachShadow to add the stylus, it is not recommended, but it is functional, if you really need to add styling to elements inside the shadowR oot, this will work.