Cuberealm.io COOL-RAY XRAY SCRIPT 😎

A super simple, safe, and cool xray script for cuberealm 😎

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Cuberealm.io COOL-RAY XRAY SCRIPT 😎
// @namespace   cooluser1481
// @match       https://cuberealm.io/*
// @version     1.1.0
// @author      cooluser1481
// @description A super simple, safe, and cool xray script for cuberealm 😎
// @license     GPL3
// ==/UserScript==

(function() {
    const createOnceExecutor = (function() {
  let isFirstCall = true;
  return function(context, func) {
    const wrapper = isFirstCall
      ? function() {
        if (func) {
          const result = func.apply(context, arguments);
          func = null;
          return result;
        }
      }
      : function() {};
    isFirstCall = false;
    return wrapper;
  };
})();

const createWrapper = (function() {
  let isFirstCall = true;
  return function(context, func) {
    const wrapper = isFirstCall
      ? function() {
        if (func) {
          const result = func.apply(context, arguments);
          func = null;
          return result;
        }
      }
      : function() {};
    isFirstCall = false;
    return wrapper;
  };
})();

let webSocketLoaded = false;
// Array of block IDs to replace
const blocksToReplace = [4, 6, 8, 10, 144];
const replacementBlockId = 78;

const webSocketProxy = new Proxy(window.WebSocket, {
  construct(target, args) {
    const ws = new target(...args);

    setTimeout(() => {
      showToast('COOLUSSR XRAY LOADED');
    }, 500);

    webSocketLoaded = true;

    ws.addEventListener('message', (event) => {
      const dataView = new DataView(event.data);

      if (dataView.getUint8(0) !== 17) {
        return;
      }

      switch (dataView.getUint8(1)) {
        case 1: {
          let offset = 16;
          if (dataView.getUint8(offset++) > 0) {
            const length = dataView.getUint16(offset);
            offset += 2;

            for (let i = 0; i < length; i++) {
              offset += 2;
              const currentBlockId = dataView.getUint16(offset);
              if (blocksToReplace.includes(currentBlockId)) {
                dataView.setUint16(offset, replacementBlockId);
              }
              offset += 2;
            }
          } else {
            for (let i = 0; i < 32768; i++) {
              const currentBlockId = dataView.getUint16(offset);
              if (blocksToReplace.includes(currentBlockId)) {
                dataView.setUint16(offset, replacementBlockId);
              }
              offset += 2;
            }
          }
          break;
        }
        default: {
          break;
        }
      }
    });

    return ws;
  },
});
window.WebSocket = webSocketProxy;

const cssLink = {
  rel: 'stylesheet',
  type: 'text/css',
  href: 'https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css',
};
document.head.appendChild(
  Object.assign(document.createElement('link'), cssLink)
);

const scriptTag = {
  type: 'text/javascript',
  src: 'https://cdn.jsdelivr.net/npm/toastify-js',
};
document.head.appendChild(
  Object.assign(document.createElement('script'), scriptTag)
);

const showToast = (message) => {
  try {
    const toastConfig = {
      text: message,
      duration: 5000,
      gravity: 'top',
      close: true,
      position: 'center',
      style: {
        background: 'linear-gradient(138deg, #009EFFFF, #39FF4AFF)',
      }
    };
    window.Toastify(toastConfig).showToast();
  } catch (e){}
};

setTimeout(() => {
  showToast('coolussr xray enabled!'.toUpperCase());
}, 500);

setTimeout(() => {
  if (!webSocketLoaded && location.hash.startsWith('#')) {
    showToast('Failed to load xray, try reloading the tab.');
  }
}, 5000);
})();