CubeRealm Special Block Finder

Highlight special blocks on CubeRealm.io when holding down the 'v' key for 3 seconds

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         CubeRealm Special Block Finder
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Highlight special blocks on CubeRealm.io when holding down the 'v' key for 3 seconds
// @author       Your Name
// @match        https://cuberealm.io/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let keyDownTime = 0;
    let isHighlighting = false;
    const highlightDuration = 3000; // 3 seconds

    // Define the special block types you want to highlight
    const specialBlocks = ['gold', 'diamond', 'platinum']; // Add more as needed

    // Function to highlight special blocks
    function highlightSpecialBlocks() {
        const blocks = document.querySelectorAll('.block'); // Assuming special blocks have a common class like 'block'

        blocks.forEach(block => {
            const blockType = block.getAttribute('data-type'); // Assuming block type is stored in a data attribute like 'data-type'

            if (specialBlocks.includes(blockType)) {
                block.style.border = '2px solid red'; // Apply a red border to highlight the block
            }
        });
    }

    // Event listener for keydown event
    document.addEventListener('keydown', function(event) {
        if (event.key === 'v') {
            keyDownTime = new Date().getTime();
            isHighlighting = true;
        }
    });

    // Event listener for keyup event
    document.addEventListener('keyup', function(event) {
        if (event.key === 'v') {
            let keyUpTime = new Date().getTime();
            if (isHighlighting && keyUpTime - keyDownTime >= highlightDuration) {
                highlightSpecialBlocks();
            }
            isHighlighting = false;
        }
    });

    // Array of special block selectors from the other script
    const specialBlockSelectors = [
        ".gold-block",
        ".diamond-block",
        ".platinum-block",
        // Add more selectors as needed
    ];

    // Function to highlight a block and extract its name
    function highlightAndGetName(selector) {
        const blocks = document.querySelectorAll(selector);
        blocks.forEach(block => {
            block.style.backgroundColor = "yellow";
            block.style.border = "2px solid orange";

            // Extract the block name from its element (adjust based on HTML structure)
            const blockNameElement = block.querySelector(".block-name");
            const blockName = blockNameElement ? blockNameElement.textContent : "Unknown";

            console.log(`Highlighted ${selector}: ${blockName}`);
        });
    }

    // Loop through the selectors and highlight the corresponding blocks
    specialBlockSelectors.forEach(selector => {
        highlightAndGetName(selector);
    });
})();