GM.addStyle Polyfill

Polyfill for GM.addStyle, for some reason their script doesn't work?

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/35383/231590/GMaddStyle%20Polyfill.js

  1. // ==UserScript==
  2. // @name GM.addStyle Polyfill
  3. // @namespace https://orbitalzero.ovh/scripts
  4. // @version 0.01
  5. // @description Polyfill for GM.addStyle, for some reason their script doesn't work?
  6. // @author NeutronNoir
  7. //
  8. // ==/UserScript==
  9. GM.addStyle = function (aCss) {
  10. 'use strict';
  11. let head = document.getElementsByTagName('head')[0];
  12. if (head) {
  13. let style = document.createElement('style');
  14. style.setAttribute('type', 'text/css');
  15. style.textContent = aCss;
  16. head.appendChild(style);
  17. return style;
  18. }
  19. return null;
  20. };