WME Zoom Level

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

目前為 2016-01-05 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();
})();