WME Zoom Level

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

2016-01-05 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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