Waze Map Editor - Validator fix

hack to put WME Validator 1.1.20 working with last WME

  1. // ==UserScript==
  2. // @name Waze Map Editor - Validator fix
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.2
  5. // @description hack to put WME Validator 1.1.20 working with last WME
  6. // @author Delfim Machado - dbcm@profundos.org
  7. // @author Glodenox - https://github.com/Glodenox
  8. // @match https://beta.waze.com/*editor/*
  9. // @match https://www.waze.com/*editor/*
  10. // @exclude https://www.waze.com/*user/*editor/*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // got from WME webpackJsonp
  15. (function(e, t, i) {
  16. "use strict";
  17. var n;
  18.  
  19. var s_defined = function(e) {
  20. return "undefined" != typeof e && null !== e;
  21. };
  22.  
  23. n = OpenLayers.Class(OpenLayers.Renderer.SVG, {
  24. initialize: function() {
  25. OpenLayers.Renderer.SVG.prototype.initialize.apply(this, arguments),
  26. this.supportUse = !0;
  27. },
  28. setAnimation: function(e, t) {
  29. var i = document.createElementNS(this.xmlns, "animate");
  30. i.setAttributeNS(null, "attributeName", t.attributeName),
  31. i.setAttributeNS(null, "dur", t.dur),
  32. t.from && i.setAttributeNS(null, "from", t.from),
  33. t.to && i.setAttributeNS(null, "to", t.to),
  34. t.fill && i.setAttributeNS(null, "fill", t.fill),
  35. t.begin && i.setAttributeNS(null, "begin", t.begin),
  36. t.id && i.setAttributeNS(null, "id", t.id),
  37. t.fill && i.setAttributeNS(null, "fill", t.fill),
  38. e.appendChild(i);
  39. },
  40. setStyle: function(e, t, i) {
  41. if (OpenLayers.Renderer.SVG.prototype.setStyle.apply(this, arguments),
  42. t.animation && this.setAnimation(e, t.animation),
  43. t.mask && e.setAttributeNS(null, "mask", t.mask),
  44. t.filter && e.setAttributeNS(null, "filter", t.filter),
  45. s_defined(t.rx) && e.setAttributeNS(null, "rx", t.rx),
  46. s_defined(t.ry) && e.setAttributeNS(null, "ry", t.ry),
  47. s_defined(t.maskID)) {
  48. var n, r = document.getElementById(t.maskID);
  49. r || (r = document.createElementNS(this.xmlns, "mask"),
  50. n = document.createElementNS(this.xmlns, "rect"),
  51. n.setAttributeNS(null, "x", "0"),
  52. n.setAttributeNS(null, "y", "0"),
  53. n.setAttributeNS(null, "width", "100%"),
  54. n.setAttributeNS(null, "height", "100%"),
  55. n.setAttributeNS(null, "fill", "white"),
  56. r.setAttributeNS(null, "id", t.maskID),
  57. r.appendChild(n)),
  58. r.appendChild(e),
  59. r._style = t,
  60. e = r;
  61. }
  62. return e;
  63. },
  64. importSymbol: function(e) {
  65. return this.symbolMetrics = {},
  66. this.symbolMetrics[e] = [0, 0, 0],
  67. e;
  68. },
  69. getNodeType: function(e, t) {
  70. var i;
  71. return i = OpenLayers.Renderer.SVG.prototype.getNodeType.apply(this, arguments),
  72. "circle" === i && s_defined(t.rx) && s_defined(t.ry) && (i = "ellipse"),
  73. i;
  74. },
  75. dashStyle: function(e, t) {
  76. var i;
  77. if (e.strokeDashArray)
  78. return e.strokeDashArray;
  79. i = e.strokeWidth * t;
  80. var n = e.strokeDashstyle;
  81. switch (n) {
  82. case "solid":
  83. return "none";
  84. case "dot":
  85. return [1, 4 * i].join();
  86. case "dash":
  87. return [4 * i, 4 * i].join();
  88. case "dashdot":
  89. return [4 * i, 4 * i, 1, 4 * i].join();
  90. case "longdash":
  91. return [8 * i, 4 * i].join();
  92. case "longdashdot":
  93. return [8 * i, 4 * i, 1, 4 * i].join();
  94. default:
  95. return OpenLayers.String.trim(n).replace(/\s+/g, ",");
  96. }
  97. },
  98. CLASS_NAME: "Waze.Renderer.ExtendedSVG"
  99. });
  100.  
  101. window.ExtendedSVG = n;
  102. })();
  103.  
  104. // translations hack
  105. if (typeof I18n.translations.en == 'undefined') {
  106. I18n.translations["en"] = {
  107. "layers": {
  108. "name": {}
  109. }
  110. };
  111. }
  112.  
  113. // create proxy for require
  114. var reqold = window.require;
  115. window.require = function(e) {
  116. if (e === 'Waze/Renderer/ExtendedSVG') {
  117. return this.ExtendedSVG;
  118. }
  119. return reqold(e);
  120. };