Light or Dark

library to determine if the color parameter is a 'light' or a 'dark' color

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/491888/1827644/Light%20or%20Dark.js

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!)

Advertisement:

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!)

Advertisement:

Аўтар
escctrl
Версія
1.1
Створаны
07.04.2024
Абноўлены
17.05.2026
Памер
994 байта
Ліцэнзія
GNU GPL-3.0-only

✍️ How to use it

Call the function lightOrDark() with the color you want to test.
Returns string "light" or "dark" accordingly.

For example:

const bgLightOrDark = lightOrDark(window.getComputedStyle(document.body).backgroundColor);