Greasy Fork is available in English.

Building Search Tool

Search for buildings by ID.

// ==UserScript==
// @name         Building Search Tool
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Search for buildings by ID.
// @author       C0MPL3X GROUP
// @match        https://junon.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const thirdMenu = document.createElement('div');
    thirdMenu.style.position = 'absolute';
    thirdMenu.style.backgroundColor = 'rgba(255, 255, 255, 0.8)';
    thirdMenu.style.border = '1px solid #ccc';
    thirdMenu.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.5)';
    thirdMenu.style.zIndex = '9999';
    thirdMenu.style.display = 'none';

    const menuHeader = document.createElement('div');
    menuHeader.textContent = 'Search by ID';
    menuHeader.style.backgroundColor = '#f1f1f1';
    menuHeader.style.padding = '5px';
    menuHeader.style.cursor = 'move';

    const idInput = document.createElement('input');
    idInput.placeholder = 'Enter ID';
    idInput.style.marginTop = '5px';

    const searchButton = document.createElement('button');
    searchButton.textContent = 'SEARCH';
    searchButton.style.marginTop = '5px';

    const coordsDisplay = document.createElement('div');
    coordsDisplay.style.marginTop = '5px';

    searchButton.addEventListener('click', () => {
        const id = idInput.value;

        if (id) {
            const game = window.game;
            if (game) {
                game.MAX_ZOOM_LEVEL = 250;
                game.zoom(50);
                const building = game.sector.buildings[id];

                if (building) {
                    const row = building.getRow();
                    const col = building.getCol();
                    const health = building.getHealth();
                    const maxHealth = building.getMaxHealth();
                    const typeName = building.getTypeName();
                    const typeId = building.getType();
                    const ownerName = building.owner.name;
                    const team = ownerName === game.sector.name ? 'owner' : ownerName;

                    const coordsText = `Coordinates: ${row} ${col}`;
                    const healthText = `HP: ${health}/${maxHealth}`;
                    const typeText = `Type: ${typeName} (${typeId})`;
                    const teamText = `Team: ${team}`;

                    coordsDisplay.innerHTML = `${coordsText}<br>${healthText}<br>${typeText}<br>${teamText}`;
                } else {
                    coordsDisplay.textContent = 'Building not found.';
                }

                setTimeout(() => {
                    game.zoom(1);
                }, 500);
            } else {
                coordsDisplay.textContent = 'Game object not found.';
            }
        } else {
            coordsDisplay.textContent = 'Please enter an ID.';
        }
    });

    thirdMenu.appendChild(menuHeader);
    thirdMenu.appendChild(idInput);
    thirdMenu.appendChild(searchButton);
    thirdMenu.appendChild(coordsDisplay);
    document.body.appendChild(thirdMenu);

    document.addEventListener('keydown', (event) => {
        if (event.code === 'End') {
            thirdMenu.style.display = thirdMenu.style.display === 'none' ? 'block' : 'none';
        }
    });
})();