WME Segment Id Copy

Captura Id de segmentos

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         WME Segment Id Copy
// @name:en      WME Segment Id Copy
// @namespace    https://greasyfork.org/es/users/381587-vitoco
// @version      0.8
// @description  Captura Id de segmentos
// @description:en  Captures segment Id
// @author       witoco
// @match        https://beta.waze.com/*editor*
// @match        https://www.waze.com/*editor*
// @match        https://www.waze.com/*/*editor*
// @exclude      https://www.waze.com/*user/*editor/*
// @grant        none
// @license      MIT
// ==/UserScript==

/* global W */
/* global $ */

(function() {
    'use strict';

    var estilo;
    var bloque;

    function bootstrap(intentos) {
        if (W && W.map && W.model && W.loginManager.user && $ ) {
            init();
        } else if (intentos < 1000) {
            setTimeout(function () {bootstrap(intentos++);}, 200);
        }
    }

    function init() {
        setTimeout(function() {var myVar = setInterval(accion ,500);}, 2000);
    }

    function accion() {
        if (W.selectionManager.getSelectedFeatures().length == 1) {
            var objeto = W.selectionManager.getSelectedFeatures()[0].featureType;
            if (objeto == "segment" || objeto == "venue") {
                var boton = document.querySelector("#edit-panel > div > div > div > wz-section-header").shadowRoot.querySelector("div > div.text-wrapper > wz-caption");
                if (!boton.onclick) {
                    boton.style.backgroundColor = '#FFFFC0';
                    boton.style.cursor = 'pointer';
                    boton.title = 'Capture ' + objeto + ' Id';
                    var segmento = W.selectionManager.getSelectedFeatures()[0]._wmeObject.attributes;
                    boton.onclick = function() {
                       var $temp = $("<textarea>");
                        $("body").append($temp);
                        $temp.val(segmento.id).select();
                        document.execCommand("copy");
                        $temp.remove();
                        boton.style.backgroundColor = 'lime';
                    };
                }
            }
        }
    }

    bootstrap(1);
})();