您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
inject styles of stylus-addon in shadowRoot
当前为
// ==UserScript== // @name Inject Stylus into shadowRoots // @name:pt-BR Injetar Stylus em shadowRoots // @namespace https://gf.qytechs.cn/users/821661 // @version 1.1 // @description inject styles of stylus-addon in shadowRoot // @description:pt-BR injeta estilos do stylus-addon em shadowRoot // @author hdyzen // @run-at document-start // @match https://*/* // @grant none // @license GPL-3.0-only // ==/UserScript== const sheet = new CSSStyleSheet(); const originalShadowRootDescriptor = Object.getOwnPropertyDescriptor(ShadowRoot.prototype, "adoptedStyleSheets"); const originalAttachShadow = Element.prototype.attachShadow; function syncStyles() { const css = [...document.querySelectorAll("html > style.stylus")].map((s) => s.textContent).join("\n"); sheet.replaceSync(css); } Element.prototype.attachShadow = function (init) { const shadowRoot = originalAttachShadow.call(this, init); shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, sheet]; return shadowRoot; }; Object.defineProperty(ShadowRoot.prototype, "adoptedStyleSheets", { get() { return originalShadowRootDescriptor.get.call(this); }, set(newSheets) { const sheets = [...newSheets]; if (!sheets.includes(sheet)) { sheets.push(sheet); } originalShadowRootDescriptor.set.call(this, sheets); }, configurable: true, enumerable: true, }); new MutationObserver(syncStyles).observe(document.documentElement, { childList: true, subtree: true, characterData: true, });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址