🏠 Home 

Greasy Fork is available in English.

style-shims

Shims for GM_addStyle and GM.addStyle.

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.org/scripts/483122/1304475/style-shims.js

  1. // ==UserScript==
  2. // @name style-shims
  3. // @description Shims for GM_addStyle and GM.addStyle.
  4. // @author Jason Kwok
  5. // @namespace https://jasonhk.dev/
  6. // @version 1.0.3
  7. // @license MIT
  8. // ==/UserScript==
  9. let GM_addStyle = function GM_addStyle(css)
  10. {
  11. const style = document.createElement("style");
  12. style.setAttribute("type", "text/css");
  13. style.textContent = css;
  14. const target = document.head ?? document.documentElement;
  15. return target.appendChild(style);
  16. }
  17. GM.addStyle = GM_addStyle;