Filter remover

用于去除网页灰色滤镜

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Filter remover
// @version      1.12
// @namespace    filter.404
// @license      GNU General Public License v3.0
// @description  用于去除网页灰色滤镜
// @author       eduarte
// @match      http://*/*
// @match      https://*/*
// @run-at       document-end
// ==/UserScript==

//
// 没有真相的致哀是对牺牲者的亵渎
// 一个阻止人们自发纪念活动的政府,更没有资格搞什么「公祭日」
// 我们需要这种带着反思的具体的悼念,希望将来某天,除了反思,还有追责
//

(function() {
    'use strict';
    let style = document.createElement('style');
    style.innerHTML = "*{filter: none !important; -webkit-filter: none !important; -moz-filter: none !important}html{filter: none !important; -webkit-filter: none !important; -moz-filter: none !important}body{filter: none !important; -webkit-filter: none !important; -moz-filter: none !important}";
    document.body.appendChild(style);
    let imgs = document.getElementsByTagName("img")
    for (let index in imgs) {
        if (imgs[index].getAttribute) {
            if (imgs[index].getAttribute("src") !== null) {
                imgs[index].setAttribute("src", imgs[index].getAttribute("src").replace("_gray", ""));
            }
            if (imgs[index].getAttribute("data-src") !== null) {
                imgs[index].setAttribute("data-src", imgs[index].getAttribute("data-src").replace("_gray", ""));
            }
        }
    }
    const removeFilter = () => {
        document.documentElement.style.setProperty('filter', 'none', 'important');
        document.body.style.setProperty('filter', 'none', 'important');
        // weibo
        let elems = document.querySelectorAll("[class*='gray']")
        for (let index in elems) {
            if (elems[index].getAttribute) {
                let classVal = elems[index].getAttribute("class");
                elems[index].setAttribute("class", classVal.replace("gray", ""));
            }
        }
    }
    let patience = 20;
    let interval;
    window.onload = () => {
        interval = setInterval(() => {
            if (document.querySelectorAll("[class*='gray']").length > 0) {
                removeFilter();
                patience = 20
            };
            patience--;
            if (patience === 0) clearInterval(interval);
        }, 100);
    }
})();