diff --git a/README.md b/README.md index 2625a2f..03c613d 100644 --- a/README.md +++ b/README.md @@ -121,3 +121,7 @@ - 兼容 img 的 `srcset` 属性 - 去掉重复的资源 - 修改按钮的动态透明度,不遮挡内容 + +## 黑白 + +黑白化网站。 \ No newline at end of file diff --git a/scripts/black-and-white.js b/scripts/black-and-white.js new file mode 100644 index 0000000..687d0f0 --- /dev/null +++ b/scripts/black-and-white.js @@ -0,0 +1,19 @@ +// ==UserScript== +// @name 黑白 +// @namespace https://github.com/yujinpan/tampermonkey-extension +// @version 1.0 +// @license MIT +// @description 网站黑白化。 +// @author yujinpan +// @include http*://** +// ==/UserScript== + +(function () { + var html = document.querySelector('html'); + var style = html.getAttribute('style') || ''; + if (style && style.slice(-1) !== ';') style += ';'; + html.setAttribute('style', + style + + 'filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);' + + 'filter: grayscale(100%);'); +})(); \ No newline at end of file