Greasy Fork

灰色网页变彩色

取消各网站首页变灰

// ==UserScript==
// @name         灰色网页变彩色
// @version      0.1
// @description  取消各网站首页变灰
// @author       AyaSono
// @match        http://*/*
// @match        https://*/*
// @icon         https://img1.baidu.com/it/u=3816024841,1982428002&fm=253&fmt=auto&app=138&f=JPEG?w=444&h=444
// @grant        none
// @namespace https://greasyfork.org/users/992881
// ==/UserScript==

(function() {
    'use strict';
/*/
    const html = document.querySelector('html')
    if (window.getComputedStyle(html).filter === 'grayscale(1)' || window.getComputedStyle(html).filter === 'grayscale(100%)') {
        html.style.filter = 'none'
        console.log('grayscale reset')
    }
    console.log('grayscale undetected')
/*/

    function grayKiller(dom) {
        const filter = window.getComputedStyle(dom, null).getPropertyValue('filter')
        filter.includes('grayscale') && dom.style.setProperty('filter', 'none')
    }
    grayKiller(document.documentElement)
    grayKiller(document.body)

})();