Simple Dark Mode

Simple Dark Mode for any site

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         		Simple Dark Mode
// @description                 Simple Dark Mode for any site
// @namespace    		http://your.namespace.com
// @version      		0.01
// @author       		bunny777
// @grant        		none
// @match        		*://*/*
// @license MIT
// ==/UserScript==

(() => {
  'use strict';

  const toggleButton = document.createElement('button'),
    style = document.createElement('style');

  toggleButton.innerText = 'ON';
  toggleButton.style.position = 'fixed';
  toggleButton.style.width = '30px';
  toggleButton.style.top = '5px';
  toggleButton.style.right = '5px';
  toggleButton.style.padding = '5px';
  toggleButton.style.border = 'none';
  toggleButton.style.borderRadius = '20px';
  toggleButton.style.backgroundColor = '#000000';
  toggleButton.style.color = '#ffffff';
  toggleButton.style.fontSize = '10px';
  toggleButton.style.cursor = 'pointer';
  toggleButton.style.boxShadow = '2px';
  toggleButton.style.zIndex = 9999;
  document.body.appendChild(toggleButton);

  function darkMode() {
    style.innerText = 'html,img,video,button,svg:not(button svg),canvas {filter: invert(.9);}';
    document.head.appendChild(style);
  }
  darkMode();

  document.addEventListener('DOMContentLoaded', darkMode);
  toggleButton.addEventListener('click', () => {

    if (style.innerText === 'html,img,video,button,svg:not(button svg),canvas {filter: invert(0);}') {
      style.innerText = 'html,img,video,button,svg:not(button svg),canvas {filter: invert(.9);}';
      toggleButton.innerText = 'ON';
    } else {
      style.innerText = 'html,img,video,button,svg:not(button svg),canvas {filter: invert(0);}';
      toggleButton.innerText = 'OFF';
    }
    document.head.appendChild(style);
  });
})();