Greasy Fork

黑白网页恢复彩色

黑白网页恢复彩色,匹配所有网页,即装即用。

目前为 2022-12-02 提交的版本。查看 最新版本

// ==UserScript==
// @name         黑白网页恢复彩色
// @namespace    http://tampermonkey.net/
// @version      1.6.5
// @license      MIT
// @description  黑白网页恢复彩色,匹配所有网页,即装即用。
// @author       https://greasyfork.org/users/574395-frammolz-amanda
// @match        *://*/*
// @exclude      *://www.douyin.com*
// @exclude      *://www.bilibili.com/bangumi/*
// @exclude      *://www.bilibili.com/video/*
// @grant        none
// ==/UserScript==

(function() {
    var filter = document.createElement('style');
    filter.type = 'text/css';
    document.getElementsByTagName('head')[0].appendChild(filter);
    filter.appendChild(document.createTextNode("*{-webkit-filter:none !important;}"));
    var windowUrl = window.location.href;
    if( windowUrl.match(/https:\/\/www.baidu.com\/$/)){
        document.getElementById("s_lg_img").setAttribute("src","https://www.baidu.com/img/flexible/logo/pc/index.png");
        document.getElementById("s_lg_img_new").setAttribute("src","https://www.baidu.com/img/flexible/logo/pc/index.png");
        document.getElementById("su").style.setProperty("background-color","#4e6ef2","important");
        if (document.getElementsByClassName("index-logo-src").length==1){
            document.getElementsByClassName("index-logo-src")[0].setAttribute("src","https://www.baidu.com/img/flexible/logo/pc/result.png");
            document.getElementsByClassName("index-logo-peak")[0].setAttribute("src","https://www.baidu.com/img/flexible/logo/pc/result.png");
            document.getElementsByClassName("index-logo-srcnew")[0].setAttribute("src","https://www.baidu.com/img/flexible/logo/pc/result.png");
        }
    }
    if( windowUrl.match(/https:\/\/m.baidu.com\/$/)){
        document.getElementById("logo").getElementsByTagName("a")[0].getElementsByTagName("img")[0].setAttribute("src","https://www.baidu.com/img/flexible/logo/logo_web.png");
        document.getElementById("index-bn").style.setProperty("background-color","#4e6ef2","important");
    }
    if( windowUrl.match(/https:\/\/115.com/)){
        filter.appendChild(document.createTextNode(".container-ceiling, .container-main, .dialog-box, .feature-float, .article-reader{-webkit-filter:none !important;}"));
    }
    if( windowUrl.match(/https:\/\/www.bilibili.com\/$|https:\/\/www.bilibili.com\/\?.*/)){
        document.getElementsByClassName("v-img banner-img")[0].getElementsByTagName("source")[0].setAttribute("srcset","//i0.hdslb.com/bfs/archive/0ac04c23af3b3297bf02dca163474326898d211d.png")
    }
    if( windowUrl.match(/https:\/\/weibo.com/)){
        var body = document.body;
        if(body.classList.length){
            rev();
            function rev() {
                document.getElementById("plc_frame").getElementsByTagName("style")[0].remove();
            }
            window.onload = function (){
                const targetNode = body;
                const config = { childList: true,};
                const callback = function(mutationsList, observer) {
                    console.log(mutationsList,observer)
                    for(let mutation of mutationsList) {
                        if (mutation.type === 'childList') rev();
                    }
                };
                const observer = new MutationObserver(callback);
                observer.observe(targetNode, config);
            }

        };
    }
    if( windowUrl.match(/https:\/\/bbs.kafan.cn\/$/)){
        document.getElementById("nv_forum").style.setProperty("background-blend-mode","normal");
    }
    if( windowUrl.match(/https:\/\/www.58pic.com\/$/)){
        document.documentElement.style.setProperty("-webkit-filter","none","important");
    }
})();