Greasy Fork

去掉网站灰色背景!!!

实在受不了!于11月30日!支持百度贴吧、QQ、网易、微博、搜狐等待去背景灰色!

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

// ==UserScript==
// @name         去掉网站灰色背景!!!
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  实在受不了!于11月30日!支持百度贴吧、QQ、网易、微博、搜狐等待去背景灰色!
// @author       imzhi <[email protected]>
// @match        https://*.baidu.com/*
// @match        https://www.qq.com/*
// @match        https://www.163.com/*
// @match        https://www.sohu.com/*
// @match        https://www.sina.com.cn/*
// @match        https://weibo.com/*
// @match        https://www.toutiao.com/*
// @match        https://www.hao123.com/*
// @match        https://www.taobao.com/*
// @match        https://www.jd.com/*
// @match        https://*.1688.com/*
// @match        https://www.iqiyi.com/*
// @match        https://www.zhihu.com/*
// @match        https://www.ifeng.com/*
// @license      MIT
// @grant        GM_addStyle
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle('@charset utf-8; ._imzhi_remove_gray_bg { filter: none !important; }');

    addClass(document.querySelector('html'), '_imzhi_remove_gray_bg');

    if (location.host === 'www.qq.com') {
        addClass(document.querySelector('body'), '_imzhi_remove_gray_bg');
    }

    if (location.host === 'weibo.com') {
        addClass(document.querySelector('.grayTheme'), '_imzhi_remove_gray_bg');
    }

    if (location.host === 'www.baidu.com') {
        addClass(document.querySelector('.skin-gray-event'), '_imzhi_remove_gray_bg');
    }

    if (location.host === 'www.sina.com.cn') {
        GM_addStyle('@charset utf-8; body * { filter: none !important; }');
    }

    if (location.host === 'www.taobao.com') {
        addClass(document.querySelector('body'), '_imzhi_remove_gray_bg');
    }

    if (location.host.match(/\.1688\.com$/)) {
        addClass(document.querySelector('body'), '_imzhi_remove_gray_bg');
    }

    if (location.host === 'www.iqiyi.com') {
        setTimeout(() => {
            addClass(document.querySelector('body .gray'), '_imzhi_remove_gray_bg');
        }, 300);
    }


    function removeClass(ele,cName) {
        var arr1 = ele.className.split(' ');
        var arr2 = cName.split(" ");
        for(var i=0;i<arr2.length;i++)for(var j=arr1.length-1;j>=0;j--)(arr2[i]===arr1[j])&&arr1.splice(j,1)
        ele.className = arr1.join(" ")
    }

    function addClass(ele,cName) {
        var arr = ele.className.split(' ').concat(cName.split(" "));
        for(var i=0;i<arr.length;i++){
            for(var k=arr.length-1;k>i;k--){
                (arr[k]==="")&&arr.splice(k,1);
                (arr[i]===arr[k])&&arr.splice(k,1);
            }
        }
        ele.className = arr.join(" ");
    }
})();