OpenStreetMap Dark Mode (filter-based)

Dark Mode for OpenStreetMap tiles based on inverting the colors and then rotating the hue.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         OpenStreetMap Dark Mode (filter-based)
// @namespace    http://tampermonkey.net/
// @version      1.1.0
// @description  Dark Mode for OpenStreetMap tiles based on inverting the colors and then rotating the hue.
// @author       scy
// @license      MIT
// @match        *://www.openstreetmap.org/*
// @grant        GM_addStyle
// ==/UserScript==

// SPDX-FileCopyrightText: 2024 scy
// SPDX-License-Identifier: MIT

(function() {
    'use strict';

    GM_addStyle(`
      @media (prefers-color-scheme: dark) {
        /* Add filter to the tile images and map key. We need to include
         * .leaflet-tile-container in the selector since that's what the dimming
         * on the original site is targeting (as of 2024-11-15). */
        .leaflet-tile-container .leaflet-tile, .mapkey-table-entry td:first-child > * {
          filter: invert(95%) hue-rotate(180deg);
        }
      }
    `);
})();