夜间模式调低对比度

当浏览器开启夜间模式时调低对比度。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         夜间模式调低对比度
// @author       ChatGPT    
// @version      3
// @description  当浏览器开启夜间模式时调低对比度。
// @match        *://*/*
// @run-at       document-start
// @namespace https://greasyfork.org/users/452911
// ==/UserScript==

(function() {
    if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
        // 夜间模式已开启,添加黑色遮罩
        var overlay = document.createElement('div');
        overlay.style.position = 'fixed';
        overlay.style.backgroundColor = '#000';
        overlay.style.top = '0';
        overlay.style.left = '0';
        overlay.style.zIndex = '999999';
        overlay.style.pointerEvents = 'none';
        overlay.style.opacity = '0.20';
        overlay.style.width = '100%';
        overlay.style.height = '100%';
        document.body.appendChild(overlay);
    }
})();