style-shims

Shims for GM_addStyle and GM.addStyle.

이 스크립트는 직접 설치하는 용도가 아닙니다. 다른 스크립트에서 메타 지시문 // @require https://update.greasyfork.org/scripts/483122/1304475/style-shims.js을(를) 사용하여 포함하는 라이브러리입니다.

// ==UserScript==
// @name               style-shims
// @description        Shims for GM_addStyle and GM.addStyle.
// @author             Jason Kwok
// @namespace          https://jasonhk.dev/
// @version            1.0.3
// @license            MIT
// ==/UserScript==

let GM_addStyle = function GM_addStyle(css)
{
    const style = document.createElement("style");
    style.setAttribute("type", "text/css");
    style.textContent = css;

    const target = document.head ?? document.documentElement;
    return target.appendChild(style);
}

GM.addStyle = GM_addStyle;