WME Zoom Level

Places a numeric zoom level indicator on top of the WME zoom slider.

// ==UserScript==
// @name            WME Zoom Level
// @namespace       https://greasyfork.org/users/11629-TheLastTaterTot
// @version         0.2.4
// @description     Places a numeric zoom level indicator on top of the WME zoom slider.
// @author          TheLastTaterTot
// @include         https://editor-beta.waze.com/*editor/*
// @include         https://www.waze.com/*editor/*
// @exclude         https://www.waze.com/*user/editor/*
// @grant           none
// @icon            data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAA9CAYAAAAeYmHpAAAD8GlDQ1BJQ0MgUHJvZmlsZQAAOI2NVd1v21QUP4lvXKQWP6Cxjg4Vi69VU1u5GxqtxgZJk6XpQhq5zdgqpMl1bhpT1za2021Vn/YCbwz4A4CyBx6QeEIaDMT2su0BtElTQRXVJKQ9dNpAaJP2gqpwrq9Tu13GuJGvfznndz7v0TVAx1ea45hJGWDe8l01n5GPn5iWO1YhCc9BJ/RAp6Z7TrpcLgIuxoVH1sNfIcHeNwfa6/9zdVappwMknkJsVz19HvFpgJSpO64PIN5G+fAp30Hc8TziHS4miFhheJbjLMMzHB8POFPqKGKWi6TXtSriJcT9MzH5bAzzHIK1I08t6hq6zHpRdu2aYdJYuk9Q/881bzZa8Xrx6fLmJo/iu4/VXnfH1BB/rmu5ScQvI77m+BkmfxXxvcZcJY14L0DymZp7pML5yTcW61PvIN6JuGr4halQvmjNlCa4bXJ5zj6qhpxrujeKPYMXEd+q00KR5yNAlWZzrF+Ie+uNsdC/MO4tTOZafhbroyXuR3Df08bLiHsQf+ja6gTPWVimZl7l/oUrjl8OcxDWLbNU5D6JRL2gxkDu16fGuC054OMhclsyXTOOFEL+kmMGs4i5kfNuQ62EnBuam8tzP+Q+tSqhz9SuqpZlvR1EfBiOJTSgYMMM7jpYsAEyqJCHDL4dcFFTAwNMlFDUUpQYiadhDmXteeWAw3HEmA2s15k1RmnP4RHuhBybdBOF7MfnICmSQ2SYjIBM3iRvkcMki9IRcnDTthyLz2Ld2fTzPjTQK+M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quPyrwP+w2Yh3LjHeQFl7V3s1we7d+/+HUotBGMGq+MGIKW+KXDyxIjU7nTpgsmzZs0Kg9juhIfzzBoIW+opPfgSYju+QPqb6Bspx6kLpo/ww5QbRZbdIATvC2boVfv1hwwZ4o2oaSNYdIG8H4aNXBmxsZKIxBSDknKFrvsChZSKQDyCmSkJOOfjGbVkEE+NaYkxM5GhZo4D07TME9kLtJgEAw0EXgHMY0b7AZDXEUNQvE7KhngEJYP5nQgBE7hdyN6g5UkRMIGTKY5kHnHUB/K4PFMJKA3MVSQTLK+ZCNzu9D/KdahrhS6CRgAAAABJRU5ErkJggg==
// @run-at          document-body
// ==/UserScript==
/* jshint -W097 */
'use strict';
var updateZoom = function () {
    document.getElementById("zoomIndicator").innerHTML = Waze.map.zoom;
};

var ZoomLevelIndicator = function () {
    var zoomSlider = document.getElementsByClassName("slider")[0],
        insertZoom = document.createElement('span');

    insertZoom.style.position = "relative";
    insertZoom.style.top = "-5px";
    insertZoom.style.width = "100%";
    insertZoom.style.display = "inline-block";
    insertZoom.style.alignContent = "center";
    insertZoom.style.verticalAlign = "middle";
    insertZoom.style.lineHeight = "14px";
    insertZoom.innerHTML =
        '<div id="zoomIndicator" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); ' +
        'background: rgba(0,0,0,.5); border-radius: 100%; border: 2px solid #FFF; box-shadow: 0px 0px 5px #888; ' +
        'margin: 0; padding: auto; width: 25px; height: 25px; vertical-align: middle; text-align: center; ' +
        'color: #FFF; font-weight: bold; font-size: 14px; line-height: 22px;">#</div>';
    zoomSlider.appendChild(insertZoom);

    updateZoom();

    Waze.map.events.register("zoomend", Waze.map, updateZoom);
};

var waitCount = 0,
    maxWait = 60; //60 seconds

var tryInit_WMEZL = function () {
    try {
        if ("undefined" !== typeof Waze && Waze.map && Waze.map.zoom &&
                Waze.map.events && Waze.map.events.register &&
                document.getElementsByClassName("slider")) {
            ZoomLevelIndicator();
        } else if (waitCount++ < maxWait) {
            setTimeout(tryInit_WMEZL, 1000);
        } else {
            console.error('WMEZL:',
                'Zoom Level Indicator could not find necessary Waze map objects.');
        }
    } catch (err) {
        console.error(
            'WMEZL:',
            'WME Zoom Level Indicator failed to load due to some kind of technical script error. :(');
        console.error(err);
    }
};

tryInit_WMEZL();