Style shadowDOM

Allow stylus to target elements in shadow-root

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
Achernar
日安装量
0
总安装量
159
评分
3 1 0
版本
0.2.2
创建于
2023-02-10
更新于
2024-05-04
大小
5.3 KB
许可证
暂无
适用于

This userscript allows Stylus' users to style shadow-DOM elements that are by definition out of reach of global stylesheets.

Currently recognized userstyles managers are: "Stylus", "User JavaScript and CSS", "xStyle", "Stylish".

Any style rule whose selectors includes :host or :host-context will be injected into the shadow-root node.

By default the userscript is not running on any website. You'll have to edit the script settings (eg. in tampermonkey): open the userscript, go to the script's "settings" tab and add the mask of the website(s) you want to run it on (don't forget the trailing *).

To test:

  • (in this script's settings) add https://web.archive.org/web/* to "user matches"
  • go to https://web.archive.org/web/2/ appended with the full url of a webpage.
    eg. https://web.archive.org/web/2/https://procyon-b.github.io/programming/
  • open stylus, or one of the supported userstyles manager.
    Edit a new stylesheet, matching https://web.archive.org/web/* and create this style:
    :host * { outline: 1px solid red !important; }
    * { outline: 1px solid green !important; }
    Without the userscript, only the normal elements are outlined (in green). With the userscript the elements in the header are outlined in red.
  • this will outline all the element in the wayback machine's header with a red line. This is not possible without the userscript (try ; disable this userscript and reload the page).