WME Coordinate Extractor

Extrae coordenadas con clic derecho en el editor de Waze.

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         WME Coordinate Extractor
// @name:en      WME Coordinate Extractor
// @namespace    http://tampermonkey.net/
// @version      1.1.1
// @description  Extrae coordenadas con clic derecho en el editor de Waze.
// @description:en Extracts coordinates with a right-click in the Waze editor.
// @author       edarague
// @match        https://www.waze.com/*editor*
// @run-at       document-end
// @grant        none
// @license MIT
// ==/UserScript==
setTimeout(() => {
    const s = document.createElement('style');
    s.textContent = `
        .waze-coord-final {
            position: fixed !important;
            background: #0a0a0a !important;
            color: #00ff00 !important;
            padding: 14px 18px !important;
            border-radius: 6px !important;
            font-family: 'Courier New', monospace !important;
            font-size: 13px !important;
            font-weight: bold !important;
            z-index: 999999 !important;
            border: 2px solid #00ff00 !important;
            min-width: 250px !important;
            box-shadow: 0 4px 20px rgba(0,255,0,0.2) !important;
        }
        .waze-coord-coords {
            margin-bottom: 10px !important;
            font-size: 14px !important;
        }
        .waze-coord-actions {
            display: flex !important;
            gap: 8px !important;
        }
        .waze-coord-btn {
            flex: 1 !important;
            padding: 6px 8px !important;
            border-radius: 4px !important;
            border: 1px solid #00ff00 !important;
            background: transparent !important;
            color: #00ff00 !important;
            font-family: 'Courier New', monospace !important;
            font-size: 11px !important;
            font-weight: bold !important;
            cursor: pointer !important;
            text-align: center !important;
            transition: background 0.15s !important;
            text-decoration: none !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            gap: 4px !important;
        }
        .waze-coord-btn:hover {
            background: #00ff00 !important;
            color: #0a0a0a !important;
        }
    `;
    document.head.appendChild(s);

    window.wazeCoordExtractor = {
        getCoords: () => {
            try {
                const t = document.body.innerText;
                const m = t.match(/(\d+\.\d{4,})\s+(-?\d+\.\d{4,})/);
                return m ? { lat: parseFloat(m[1]).toFixed(6), lng: parseFloat(m[2]).toFixed(6) } : null;
            } catch (e) { return null; }
        },
        showPopup: (c, x, y) => {
            const old = document.querySelector('.waze-coord-final');
            if (old) old.remove();

            const mapsUrl = `https://maps.google.com/?q=${c.lat},${c.lng}`;

            const p = document.createElement('div');
            p.className = 'waze-coord-final';
            p.innerHTML = `
                <div class="waze-coord-coords">📍 ${c.lat} ${c.lng}</div>
                <div class="waze-coord-actions">
                    <button class="waze-coord-btn" id="wce-copy">📋 Copiar</button>
                    <a class="waze-coord-btn" href="${mapsUrl}" target="_blank" id="wce-maps">🗺️ Maps</a>
                </div>
            `;

            p.style.left = Math.min(x + 15, window.innerWidth - 240) + 'px';
            p.style.top = Math.min(y + 15, window.innerHeight - 120) + 'px';

            document.body.appendChild(p);

            document.getElementById('wce-copy').addEventListener('click', (e) => {
                e.stopPropagation();
                navigator.clipboard.writeText(`${c.lat}, ${c.lng}`);
                const btn = document.getElementById('wce-copy');
                if (btn) btn.textContent = '✅ Copiado';
                setTimeout(() => p.remove(), 1500);
            });

            document.getElementById('wce-maps').addEventListener('click', (e) => {
                e.stopPropagation();
                setTimeout(() => p.remove(), 500);
            });

            setTimeout(() => { if (p.parentNode) p.remove(); }, 6000);
        }
    };

    document.addEventListener('contextmenu', (e) => {
        const c = window.wazeCoordExtractor.getCoords();
        if (c) { e.preventDefault(); window.wazeCoordExtractor.showPopup(c, e.clientX, e.clientY); }
    }, true);
}, 500);