Cryzen.io Map Darkmode

Makes maps darkmode

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Cryzen.io Map Darkmode
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Makes maps darkmode
// @author       VALIDUSER
// @match        https://cryzen.io/*
// @grant        none
// @run-at       document-start
// ==/UserScript==
(function() {
    'use strict';
    // resource overrider
    const srcset = Object.getOwnPropertyDescriptor(Image.prototype, 'src').set;
    function getSqareDataURL(width, height, color) {
        const canvas = document.createElement('canvas');
        canvas.width = width;
        canvas.height = height;
        const context = canvas.getContext('2d');
        context.fillStyle = color;
        context.fillRect(0, 0, width, height);
        const dataURL = canvas.toDataURL();
        return dataURL;
    }
    Object.defineProperty(Image.prototype, 'src', {
        set(value) {
            this._src = value;
            if (typeof value != 'string') { return srcset.call(this, value); }
            if (value.includes('colorMap')) { value = getSqareDataURL(1, 1, '#000000'); }
            if (value.includes('map-')) { value = getSqareDataURL(1, 1, '#212121'); }
            if (value.includes('sky')) { value = getSqareDataURL(1, 1, '#212121'); }
            srcset.call(this, value);
        },
        get() { return this._src; }
    });
})();