您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
去除任意网站的黑白样式
当前为
仅仅 1.22 KB 的代码大小,运行起来如闪电一样快
当 <body>
加载时向 <head>
元素添加以下 <style>
元素,避免闪屏
<style id="grayToColorful">
* {
filter: grayscale(0) !important;
-webkit-filter: grayscale(0) !important;
-moz-filter: grayscale(0) !important;
-ms-filter: grayscale(0) !important;
-o-filter: grayscale(0) !important;
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=0) !important;
}
</style>
当纯 HTML 被完全加载以及解析时,移除 <style id="grayToColorful">
并向 <head>
元素添加以下 <style>
元素。再遍历每个元素,若使用了灰度滤镜,则给它的 class
属性添加 grayToColorful
<style>
.grayToColorful {
filter: grayscale(0) !important;
-webkit-filter: grayscale(0) !important;
-moz-filter: grayscale(0) !important;
-ms-filter: grayscale(0) !important;
-o-filter: grayscale(0) !important;
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=0) !important;
}
</style>
Q:这个脚本有什么过人之处吗?
A:此脚本仅去除 包含灰度滤镜的元素的灰度滤镜 ,不会影响其他滤镜,和其他元素。例如:一个元素既有高斯模糊,又有灰度滤镜,我们 只会去除其中的灰度滤镜,而不影响高斯模糊 。
Q:为何百度首页的 logo 和搜索按钮还是灰色?
A:因为百度 logo 并不是简单的加了一个灰度滤镜,而是图片本身就换成黑白了,bilibili 首页的轮播图也是如此。而搜索按钮是把按钮颜色改为 #222
,所以本身就是黑白的了。
解决办法只有一个个的单独适配,然而我没有这么多时间。