Greasy Fork is available in English.

OValue Exporter

Exports empire data for OValue calculator

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

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         OValue Exporter
// @name:it      OValue Exporter
// @namespace    https://greasyfork.org/users/YOUR_USER_ID
// @version      1.9.1
// @description  Exports empire data for OValue calculator
// @description:it  Esporta i dati dell'impero per il calcolatore OValue
// @author       YOUR_NAME
// @license      MIT
// @match        https://*.ogame.gameforge.com/game/index.php?page=standalone&component=empire*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ogame.gameforge.com
// @grant        GM_setClipboard
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    function exportOvalue() {
        let data = { settings: { plasma: 0 }, planets: [] };

        let plasma = 0;
        document.querySelectorAll('.planet').forEach(p => {
            if (plasma > 0) return;
            let plasmaDiv = p.querySelector('.values.research [class~="122"]');
            if (plasmaDiv) {
                let src = plasmaDiv.querySelector('a:not(.active)')
                        || plasmaDiv.querySelector('span');
                let val = 0;
                if (src) {
                    val = parseInt(src.innerText.replace(/\./g, '')) || 0;
                } else {
                    val = parseInt(plasmaDiv.innerText.replace(/\./g, '').match(/\d+/)?.[0]) || 0;
                }
                if (val > 0) plasma = val;
            }
        });
        data.settings.plasma = plasma;

        document.querySelectorAll('.planet').forEach(p => {
            let coordsText = p.querySelector('.coords')?.innerText || '';
            let match = coordsText.match(/\[\d+:\d+:(\d+)\]/);
            if (!match) return;
            let pos = parseInt(match[1]);
            let name = p.querySelector('.planetname')?.innerText.trim() || '';

            let getLevel = (container, cls) => {
                let node = p.querySelector('.' + container + ' [class~="' + cls + '"]');
                if (!node) return 0;
                let firstA = node.querySelector('a:not(.active)');
                if (firstA) {
                    let m = firstA.innerText.replace(/\./g, '').match(/\d+/);
                    if (m) return parseInt(m[0]);
                }
                let span = node.querySelector('span');
                if (span) {
                    let m = span.innerText.replace(/\./g, '').match(/\d+/);
                    if (m) return parseInt(m[0]);
                }
                let m = node.innerText.replace(/\./g, '').match(/\d+/);
                return m ? parseInt(m[0]) : 0;
            };

            let itemValue = 0;
            let itemCustomValue = 0;
            p.querySelectorAll('.item_img').forEach(img => {
                let title = img.getAttribute('data-tooltip-title') || '';
                if (title.includes('metallo Bronzo')) itemValue = Math.max(itemValue, 10);
                if (title.includes('metallo Argento')) itemValue = Math.max(itemValue, 20);
                if (title.includes('metallo Oro')) itemValue = Math.max(itemValue, 30);
                if (title.includes('metallo Platino')) itemValue = Math.max(itemValue, 40);
                let ampMatch = title.match(/Amplificatore di risorse \((\d+)/);
                if (ampMatch) itemCustomValue = parseInt(ampMatch[1]);
            });

            data.planets.push({
                name,
                pos,
                metal: getLevel('supply', '1'),
                crystal: getLevel('supply', '2'),
                deuterium: getLevel('supply', '3'),
                magma: getLevel('lifeform2buildings', '12106'),
                human: getLevel('lifeform1buildings', '11106'),
                crawlers: getLevel('ships', '217'),
                item: itemValue,
                itemCustom: itemCustomValue,
                overload: false
            });
        });

        let jsonString = JSON.stringify(data);
        if (typeof GM_setClipboard !== 'undefined') {
            GM_setClipboard(jsonString, "text");
            alert("✅ Dati OValue copiati!");
        } else {
            navigator.clipboard.writeText(jsonString).then(() => alert("✅ Dati OValue copiati!"));
        }
    }

    function createButton() {
        let targetContainer = document.querySelector('#empireTab .wrapTab .reset');
        if (!targetContainer) {
            setTimeout(createButton, 500);
            return;
        }
        if (document.getElementById('ovalue-export-btn')) return;

        let btn = document.createElement("a");
        btn.id = "ovalue-export-btn";
        btn.href = "#";
        btn.innerHTML = "Esporta OValue";
        btn.style.display = "inline-block";
        btn.style.marginLeft = "12px";
        btn.style.padding = "2px 8px";
        btn.style.background = "linear-gradient(to bottom, #25313d 0%, #171f28 100%)";
        btn.style.border = "1px solid #000";
        btn.style.borderRadius = "3px";
        btn.style.color = "#92a0b0";
        btn.style.textDecoration = "none";
        btn.style.fontFamily = "Verdana, Arial, Helvetica, sans-serif";
        btn.style.fontSize = "11px";
        btn.style.fontWeight = "bold";
        btn.style.boxShadow = "inset 0 1px 0 rgba(255,255,255,0.1), 0 1px 3px rgba(0,0,0,0.8)";
        btn.style.textTransform = "uppercase";
        btn.style.transition = "all 0.1s ease-in-out";
        btn.style.cursor = "pointer";
        btn.style.verticalAlign = "middle";

        btn.onmouseover = () => {
            btn.style.color = "#fff";
            btn.style.background = "linear-gradient(to bottom, #2f3e4c 0%, #1e2934 100%)";
            btn.style.boxShadow = "inset 0 1px 0 rgba(255,255,255,0.1), 0 1px 3px rgba(0,0,0,0.8), 0 0 5px rgba(255,255,255,0.1)";
        };
        btn.onmouseout = () => {
            btn.style.color = "#92a0b0";
            btn.style.background = "linear-gradient(to bottom, #25313d 0%, #171f28 100%)";
            btn.style.boxShadow = "inset 0 1px 0 rgba(255,255,255,0.1), 0 1px 3px rgba(0,0,0,0.8)";
        };

        btn.onclick = function(e) {
            e.preventDefault();
            exportOvalue();
        };

        targetContainer.appendChild(btn);
    }

    createButton();
})();