Cryzen.io Visible models

Makes models better visible

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Cryzen.io Visible models
// @license      MIT
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  Makes models better visible
// @author       Enth
// @match        https://cryzen.io/*
// @icon         https://media.discordapp.net/attachments/921558341791129671/1172861950347194410/image.png
// @grant        none
// @run-at       document-start
// ==/UserScript==

// 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')) {
            if (value.toLowerCase().includes('red')) {
                value = getSqareDataURL(1000, 1000, '#FF7373');
            } else if (value.toLowerCase().includes('blue')) {
                value = getSqareDataURL(1000, 1000, '#00FFFF');
            } else {
                value = getSqareDataURL(1000, 1000, '#73FF73');
            }
        }
        if (value.includes('map-')) {
            value = getSqareDataURL(4096, 2048, '#AAAAAA');
        }
        srcset.call(this, value);
    },
    get() {
        return this._src;
    }
});