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 यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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();
})();