Greasy Fork 支持简体中文。

Stylus Shadow DOM Support

Make Stylus styles also be applied to Shadow DOM elements.

< 腳本Stylus Shadow DOM Support的回應

評論:正評 - 腳本一切正常

§
發表於:2024-07-08

Sir, your code does not work when the ShadowDOM on the other side is created by the Chrome plugin. It may be a problem with the loading timing.

If you need to fix it, you need to add this paragraph:


function applyStylus() {
  const ss = document.querySelectorAll('html>style[id^="stylus-"]');
  const allShadowHosts = document.querySelectorAll('*');
  allShadowHosts.forEach(e => {
    if (!e.shadowRoot) return;
    Array.from(e.shadowRoot.children).forEach(el => chkNode(el) && el.remove());
    ss.forEach(el => e.shadowRoot.append(el.cloneNode(true)));
  });
}


發表回覆

登入以回復