豆沙绿护眼模式Plus

改网页背景色为豆沙绿

目前為 2023-10-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name         豆沙绿护眼模式Plus
// @version      4.0
// @description  改网页背景色为豆沙绿
// @author       ChatGPT
// @run-at       document-start
// @match        *://*/*
// @grant        none
// @namespace https://gf.qytechs.cn/users/452911
// ==/UserScript==

function addStyle(css) {
    const style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
    document.getElementsByTagName("head")[0].appendChild(style);
}

addStyle(`
    * {
        transition: background-color .3s ease-out, color .3s ease-out;
    }
    body, div#gb, div#main, 
    div.url.clearfix, div.nav-bar-v2-fixed > * > *:not(div.nav-bar-bottom), 
    div.se-page-hd-content {
        background-color: #C7EDCC !important;
    }
    a[href^='http']:not(.button) {
        color: #40933C !important;
        text-decoration: none !important;
    }
`);

function background() {
    let elementList = document.querySelectorAll('*');
    for(let i = 0; i< elementList.length; i++){   
        if(!(elementList[i].matches('[class*="player"] > *') || 
             elementList[i].matches('.video > *'))){
            let srcBgColor = window.getComputedStyle(elementList[i]).backgroundColor;
            let splitArray = srcBgColor.match(/[\d\.]+/g);
            let r = parseInt(splitArray[0], 10),
                g = parseInt(splitArray[1], 10),
                b = parseInt(splitArray[2], 10);
            if(r > 150 && g > 150 && b > 150) {
                elementList[i].style.backgroundColor='#C7EDCC';
            }
        }
    }
}

background();

window.onload = function() {
    background();
};

    let observer = new MutationObserver(function(mutations) {
        background();
    });
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址