WME Zoom Level

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

Verze ze dne 05. 01. 2016. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name 			WME Zoom Level
// @description 	Places a zoom level indicator on top of the WME zoom slider.
// @namespace       https://greasyfork.org/users/11629-TheLastTaterTot
// @version 		0.2.1.1
// @grant           none
// @include         https://editor-beta.waze.com/*editor/*
// @include         https://www.waze.com/*editor/*
// @exclude         https://www.waze.com/user/*editor/*
// @author			TheLastTaterTot
// ==/UserScript==
(function() {

	function ZoomLevelIndicator() {
		var UpdateZoom = function() {
			var currentZoom = Waze.map.zoom;
			document.getElementById("zoomIndicator").innerHTML = currentZoom;
		};

		var zoomSlider = document.getElementsByClassName("slider")[0],
			insertZoom = document.createElement('span'),
			indicatorCSS = document.createElement("style");

		indicatorCSS.type = "text/css";
		indicatorCSS.innerHTML =
			'.zl-indicator { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);' +
			'background: rgba(0,0,0,.5); border-radius: 100%; border: 2px solid #ffffff; box-shadow: 0px 0px 5px #888888;' +
			'margin: 0; padding: auto; width: 25px; height: 25px; vertical-align: middle; text-align: center;' +
			'color: white; font-weight: bold; font-size: 14px; line-height: 22px; }';

		document.body.appendChild(indicatorCSS);

		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" class="zl-indicator">#</div>';
		zoomSlider.appendChild(insertZoom);

		UpdateZoom();

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

	var initCount = 0;

	function Init_WMEZL() {
		if (initCount < 100) {
			initCount++;
			try {
				if ("undefined" !== typeof Waze && Waze.map &&
					Waze.map.events && Waze.map.events.register &&
					document.getElementsByClassName("slider")) {

					ZoomLevelIndicator();

				} else {
					setTimeout(Init_WMEZL, 1000);
				}
			} catch (err) {
				console.log(
					'WMEZL: WME Zoom level indicator failed to load... Will try again. ' +
					err);
				setTimeout(Init_WMEZL, 5000);
			}
		} else {
			console.log('WMEZL: WME Zoom level indicator failed to load. :( Giving up.');
		}
	}

	function Bootstrap_WMEZL() {
		var bGreasemonkeyServiceDefined = false;

		try {
			bGreasemonkeyServiceDefined = ("object" === typeof Components.interfaces.gmIGreasemonkeyService)
		} catch (err) { /* Ignore */ }

		if ("undefined" === typeof unsafeWindow || !bGreasemonkeyServiceDefined) {
			unsafeWindow = (function() {
				var dummyElem = document.createElement('p');
				dummyElem.setAttribute('onclick', 'return window;');
				return dummyElem.onclick();
			})();
		}
		setTimeout(Init_WMEZL, 500);
	}

	Bootstrap_WMEZL();
})();