Cryzen.io Map Darkmode

Makes maps darkmode

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

// ==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; }
    });
})();