OLED Pure Black Background

Change websites' background to pure black for OLED screens

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         OLED Pure Black Background
// @namespace    (link unavailable)
// @version      1.5
// @description  Change websites' background to pure black for OLED screens
// @author       Patrick Gomes
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
  'use strict';

  const css = `
    html, body {
      background-color: #000000 !important;
    }
    * {
      background-color: rgba(0, 0, 0, 0.5) !important;
      color: #8cffb5 !important;
      border-color: #444444 !important;
    }
    a {
      color: #ff66ff !important;
    }
    img {
      filter: brightness(0.8) contrast(1.2); /* Adjust brightness and contrast of images */
    }
    /* Exclude YouTube videos from brightness and contrast adjustments */
    video, .html5-video-container video {
      filter: none !important; /* Remove any filter applied to videos */
    }
  `;

  const style = document.createElement('style');
  style.type = 'text/css';
  style.appendChild(document.createTextNode(css));
  document.head.appendChild(style);

  const observer = new MutationObserver(function() {
    document.documentElement.style.backgroundColor = '#000000';
    document.body.style.backgroundColor = '#000000';
  });
  observer.observe(document, { childList: true, subtree: true });

})();