WME Google POI verifier

Verify Waze landmarks linked to Google POI

  1. // ==UserScript==
  2. // @name WME Google POI verifier
  3. // @name:cs WME Kontrola Google POI
  4. // @version 1.51
  5. // @description Verify Waze landmarks linked to Google POI
  6. // @description:cs Kontroluje landmarky ve Waze nalinkované na Google POI
  7. // @author Kebb01
  8. // @include https://www.waze.com/editor/*
  9. // @include https://www.waze.com/*/editor/*
  10. // @include https://editor-beta.waze.com/*
  11. // @include https://beta.waze.com/*/editor/*
  12. // @namespace https://greasyfork.org/cs/scripts/19122-wme-google-poi-verifier
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. function gpoi_bootstrap()
  17. {
  18. var bGreasemonkeyServiceDefined = false;
  19.  
  20. try
  21. {
  22. if ("object" === typeof Components.interfaces.gmIGreasemonkeyService)
  23. {
  24. bGreasemonkeyServiceDefined = true;
  25. }
  26. }
  27. catch (err)
  28. {
  29. //Ignore.
  30. }
  31. if ( "undefined" === typeof unsafeWindow || ! bGreasemonkeyServiceDefined)
  32. {
  33. unsafeWindow = ( function ()
  34. {
  35. var dummyElem = document.createElement('p');
  36. dummyElem.setAttribute ('onclick', 'return window;');
  37. return dummyElem.onclick ();
  38. } ) ();
  39. }
  40. /* begin running the code! */
  41. console.log("GPOI: GPOI bootstrap init");
  42. coolscript_init();
  43. }
  44.  
  45. // =========
  46. function coolscript_init()
  47. {
  48. function gpoiFunc(){
  49. function readTextFile(file, callback) {
  50. var rawFile = new XMLHttpRequest();
  51. rawFile.overrideMimeType("text/plain");
  52. rawFile.open("GET", file, true);
  53. rawFile.onreadystatechange = function() {
  54. if (rawFile.readyState === 4 && rawFile.status == "200") {
  55. callback(rawFile.responseText);
  56. }
  57. };
  58. rawFile.send(null);
  59. }
  60. setInterval(function(){ gpoiRun(); }, 3000);
  61.  
  62. function gpoiRun() {
  63.  
  64. var gLoop = 0;
  65. var gUrlArray = [];
  66. var gCodeArray = [];
  67. var gpoiDataArray = [];
  68. var gLinkArray = [];
  69. var hostName = window.location.hostname;
  70. var neKat = ["FOREST_GROVE", "RIVER_STREAM"];
  71. var neKatCount = neKat.length;
  72.  
  73. var missingGPOI = " MISSING LINKED GOOGLE MAP POI ";
  74. console.log("missingGPOI = " + missingGPOI);
  75.  
  76. function GPOICreateElement () {
  77. var element = document.createElement("div");
  78. element.style.color = '#FF0000';
  79. element.style.fontWeight = "bold";
  80. element.appendChild(document.createTextNode(missingGPOI));
  81. var missingGPOIs = document.getElementsByClassName("form-group")[12].appendChild(element);
  82. }
  83.  
  84. var gpoiCount = document.getElementsByClassName("select2-chosen");
  85. gpoiCount = gpoiCount.length;
  86.  
  87. var jeTamText = document.getElementsByClassName("form-group")[12].innerText;
  88.  
  89. var place = W.selectionManager.selectedItems[0].model;
  90. var kat = W.selectionManager.selectedItems[0].model.attributes.categories;
  91. console.log("neKat = " + neKat + ", kat = " + kat);
  92.  
  93. // tu jsem skončil
  94. if (place.type === "venue") {
  95. if (kat != "FOREST_GROVE" || kat != "RIVER_STREAM") {
  96. if (jeTamText.includes("LINKED")) {
  97. } else {
  98.  
  99. if (gpoiCount === 0) {
  100. GPOICreateElement();
  101. }
  102. }
  103. }
  104. }
  105.  
  106.  
  107.  
  108. for (i = 0; i < gpoiCount; i++) {
  109. var gCode = document.getElementsByClassName("placeId")[i].innerHTML;
  110. gCodeArray.push(gCode); // kódy WME
  111. }
  112.  
  113. for (x = 0; x < gpoiCount; x++) {
  114. var gpoiData = "https://" + hostName + "/maps/api/place/details/json?placeid=" + gCodeArray[x] + "&key=AIzaSyBIfV0EMXrTDjrvD92QX5bBiyFmBbT-W8E";
  115. gpoiDataArray.push(gpoiData); /// linky k json datům
  116. }
  117.  
  118. for (y = 0; y < gpoiCount; y++) {
  119. readTextFile(gpoiDataArray[y], function(text){
  120. var data = JSON.parse(text);
  121. console.log("gpoiData = " + gpoiData);
  122. var url = data.result.url;
  123. gUrlArray.push(url);
  124.  
  125. for (y1 = 0; y1 < gpoiCount; y1++) {
  126. // var gLink = '<a href = "' + gUrlArray[y1] + '" target = "_blank">' + gCodeArray[y1] + '</a>';
  127. var gLink = '<a href = "' + gUrlArray[y1] + '" target = "_blank">' + "» GoogleMap POI #" + [y1+1] + '</a>';
  128. gLinkArray.push(gLink);
  129. }
  130. if (gpoiCount == 1) {
  131. for (z = 0; z < gpoiCount; z++) {
  132. document.getElementsByClassName("placeId")[z].innerHTML = gLinkArray[z];
  133. }
  134. }
  135. if (gpoiCount > 1) {
  136. for (z = gpoiCount; z < gpoiCount+gpoiCount; z++) {
  137. document.getElementsByClassName("placeId")[z-gpoiCount].innerHTML = gLinkArray[z];
  138. }
  139. }
  140. });
  141. }
  142. }
  143. }
  144. gpoiFunc();
  145. }
  146.  
  147. // then at the end of your script, call the bootstrap to get things started
  148. gpoi_bootstrap();