Waze Map Editor - Validator fix

hack to put WME Validator 1.1.20 working with last WME

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Waze Map Editor - Validator fix
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @description  hack to put WME Validator 1.1.20 working with last WME
// @author       Delfim Machado - [email protected]
// @author       Glodenox - https://github.com/Glodenox
// @match        https://beta.waze.com/*editor/*
// @match        https://www.waze.com/*editor/*
// @exclude      https://www.waze.com/*user/*editor/*
// @grant        none
// ==/UserScript==

// got from WME webpackJsonp
(function(e, t, i) {
	"use strict";
	var n;

	var s_defined = function(e) {
		return "undefined" != typeof e && null !== e;
	};

	n = OpenLayers.Class(OpenLayers.Renderer.SVG, {
		initialize: function() {
			OpenLayers.Renderer.SVG.prototype.initialize.apply(this, arguments),
				this.supportUse = !0;
		},
		setAnimation: function(e, t) {
			var i = document.createElementNS(this.xmlns, "animate");
			i.setAttributeNS(null, "attributeName", t.attributeName),
				i.setAttributeNS(null, "dur", t.dur),
				t.from && i.setAttributeNS(null, "from", t.from),
				t.to && i.setAttributeNS(null, "to", t.to),
				t.fill && i.setAttributeNS(null, "fill", t.fill),
				t.begin && i.setAttributeNS(null, "begin", t.begin),
				t.id && i.setAttributeNS(null, "id", t.id),
				t.fill && i.setAttributeNS(null, "fill", t.fill),
				e.appendChild(i);
		},
		setStyle: function(e, t, i) {
			if (OpenLayers.Renderer.SVG.prototype.setStyle.apply(this, arguments),
				t.animation && this.setAnimation(e, t.animation),
				t.mask && e.setAttributeNS(null, "mask", t.mask),
				t.filter && e.setAttributeNS(null, "filter", t.filter),
				s_defined(t.rx) && e.setAttributeNS(null, "rx", t.rx),
				s_defined(t.ry) && e.setAttributeNS(null, "ry", t.ry),
				s_defined(t.maskID)) {
				var n, r = document.getElementById(t.maskID);
				r || (r = document.createElementNS(this.xmlns, "mask"),
						n = document.createElementNS(this.xmlns, "rect"),
						n.setAttributeNS(null, "x", "0"),
						n.setAttributeNS(null, "y", "0"),
						n.setAttributeNS(null, "width", "100%"),
						n.setAttributeNS(null, "height", "100%"),
						n.setAttributeNS(null, "fill", "white"),
						r.setAttributeNS(null, "id", t.maskID),
						r.appendChild(n)),
					r.appendChild(e),
					r._style = t,
					e = r;
			}
			return e;
		},
		importSymbol: function(e) {
			return this.symbolMetrics = {},
				this.symbolMetrics[e] = [0, 0, 0],
				e;
		},
		getNodeType: function(e, t) {
			var i;
			return i = OpenLayers.Renderer.SVG.prototype.getNodeType.apply(this, arguments),
				"circle" === i && s_defined(t.rx) && s_defined(t.ry) && (i = "ellipse"),
				i;
		},
		dashStyle: function(e, t) {
			var i;
			if (e.strokeDashArray)
				return e.strokeDashArray;
			i = e.strokeWidth * t;
			var n = e.strokeDashstyle;
			switch (n) {
				case "solid":
					return "none";
				case "dot":
					return [1, 4 * i].join();
				case "dash":
					return [4 * i, 4 * i].join();
				case "dashdot":
					return [4 * i, 4 * i, 1, 4 * i].join();
				case "longdash":
					return [8 * i, 4 * i].join();
				case "longdashdot":
					return [8 * i, 4 * i, 1, 4 * i].join();
				default:
					return OpenLayers.String.trim(n).replace(/\s+/g, ",");
			}
		},
		CLASS_NAME: "Waze.Renderer.ExtendedSVG"
	});

	window.ExtendedSVG = n;
})();

// translations hack
if (typeof I18n.translations.en == 'undefined') {
	I18n.translations["en"] = {
		"layers": {
			"name": {}
		}
	};
}

// create proxy for require
var reqold = window.require;
window.require = function(e) {
	if (e === 'Waze/Renderer/ExtendedSVG') {
		return this.ExtendedSVG;
	}
	return reqold(e);
};