Greasy Fork

Greasy Fork is available in English.

不要黑白

多彩世界

当前为 2022-12-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         不要黑白
// @namespace    https://keep-silence.com/
// @version      0.1
// @license      MIT
// @description  多彩世界
// @author       Ghosie
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 处理百度
    function dealBaidu(page) {
        if (page === 'index') {
            const body = document.querySelector('.big-event-gray')
            if (body) {
                body.className = ''
                document.getElementById('lg').firstElementChild.onerror()
            }
            return
        }
        if (page === 'tieba') {
            if (document.documentElement.className === 'tb-allpage-filter') {
                document.documentElement.style.filter = 'grayscale(0)'
            }
        }
    }

    // 处理微博
    function dealWeibo() {
        const lists = document.querySelectorAll('.grayTheme')
        lists.forEach(item => {
            item.className = item.className.slice(0, item.className.indexOf('grayTheme'))
        })
    }

    // 处理 it之家
    function dealIthome() {
        const lists = document.querySelectorAll('*')
        const len = lists.length
        for (let i = 0; i < len; i++) {
            lists[i].style.filter = 'grayscale(0)'

        }
    }

    const href = window.location.href

    if (/www\.baidu/.test(href)) {
        dealBaidu('index')
    } else if (/tieba/.test(href)) {
        dealBaidu('tieba')
    } else if (/weibo/.test(href)) {
        setTimeout(() => {
            dealWeibo()
        }, 0)
    }else if (/ithome/.test(href)) {
        dealIthome()
    } else {
        document.documentElement.style.filter = 'grayscale(0)'
    }
})();