// ==UserScript== // @name Anti-Grayscale // @description 移除页面的灰色模式 (恢复页面的彩色模式). Remove grayscale of html page (Restore color mode of html page). // @version 2.0 // @author xcanwin // @namespace https://github.com/xcanwin/Anti-Grayscale/ // @supportURL https://github.com/xcanwin/Anti-Grayscale/ // @updateURL https://raw.githubusercontent.com/xcanwin/Anti-Grayscale/main/Anti-Grayscale.user.js // @downloadURL https://raw.githubusercontent.com/xcanwin/Anti-Grayscale/main/Anti-Grayscale.user.js // @icon data:image/svg+xml;utf8, // @license GPL-2.0-only // @match *://*/* // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; const $ = (Selector, el) => (el || document).querySelector(Selector); const $$ = (Selector, el) => (el || document).querySelectorAll(Selector); const main = () => { $$("*").forEach(el => { [ "filter", "-webkit-filter", "-moz-filter", "-ms-filter", "-o-filter", ].forEach(xcanwin => { const re = /grayscale\(.*?\)/gi; const style = document.defaultView.getComputedStyle(el, null)[xcanwin]; if (style && style.match(re)) { el.style.setProperty(xcanwin, style.replace(re, "grayscale(0)"), "important"); } }); }); }; main(); })();