WME Zoom Level

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

Stan na 05-01-2016. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
})();