Cryzen.io Visible models

Makes models better visible

< 脚本Cryzen.io Visible models的反馈

评价:差评 - 脚本失效或无法使用

Deleted user 1217476
§
发表于:2023-11-30

// ==UserScript==
// @name Cryzen.io Refined Map Transparency
// @license MIT
// @namespace http://tampermonkey.net/
// @version 1.0.0
// @description Enables conditional map transparency by pressing the key "M" and disconnects WebSockets on "`" on Cryzen.io
// @author Enth
// @match https://cryzen.io/*
// @icon https://media.discordapp.net/attachments/921558341791129671/1172861950347194410/image.png
// @grant none
// @run-at document-start
// ==/UserScript==

function main() {
// Resource overrider
const srcset = Object.getOwnPropertyDescriptor(Image.prototype, 'src').set;
let mapTransparent = false; // Variable to track map transparency state

const mapWebsockets = [];
window.WebSocket = new Proxy(WebSocket, {
construct(target, args) {
const ws = new target(...args);
mapWebsockets.push(ws);
return ws;
}
});

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;
}

// Event listener for key press
document.addEventListener('keyup', function (event) {
if (event.key === 'm') { // Key 'M' for map transparency
mapTransparent = !mapTransparent;
}
});

// Event listener for key press using window
window.addEventListener('keydown', ({ keyCode, which }) => {
switch (keyCode || which) {
case 192: // Key '`' for disconnecting WebSockets
if (confirm('Are you sure that you want to disconnect from the server?')) {
disconnectWebsockets();
}
break;
// Add more cases as needed
default:
break;
}
});

function disconnectWebsockets() {
for (const ws of mapWebsockets) {
ws.onmessage = null;
ws.onerror = null;
ws.onclose = null;
ws.close();
}
}

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, '#7373ff');
} else {
value = getSqareDataURL(1000, 1000, '#ff0000');
}
}
if (value.includes('map-')) {
// Check if map should be transparent based on the variable
value = mapTransparent ? getSqareDataURL(4096, 2048, 'rgba(0,0,0,0)') : getSqareDataURL(4096, 2048, '#bfbfbf');
}
srcset.call(this, value);
},
get() {
return this._src;
}
});
}

document.addEventListener('DOMContentLoaded', main);

This code makes the map invisble but i dont know how to make it so when i press like x it makes it invisible and when i press x again it makes it visble please help

发表回复

登录(不可用)以发表回复。

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址