Style shadowRoot

Allow stylus to target elements in shadow-root

目前為 2023-02-10 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
Achernar
評價
0 0 0
版本
0.1
建立日期
2023-02-10
更新日期
2023-02-10
尺寸
4.4 KB
授權條款
未知
腳本執行於

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

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 style settings (eg. in tampermonkey): open the userstyle, go to the style's "settings" tab and add the mask (don't forget the *) of the website(s) you want to run it on.

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. Edit a new stylesheet, matching https://web.archive.org/web/* and define this style: :host * { outline: 1px solid red !important; }
  • 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).