📜  tampermonkey 自定义 css 代码示例

📅  最后修改于: 2022-03-11 14:47:43.302000             🧑  作者: Mango

代码示例1
function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css.replace(/;/g, ' !important;');
    head.appendChild(style);
}
/*  this only works, if you use the function instead of GM_addStyle
 the output of this "addGlobalStyle('body { color: white; background-color: black; }');",

will be "body { color: white !important; background-color: black !important; }');" */