WME Fix UR Interface

Fix the UR Interface

目前为 2022-01-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name WME Fix UR Interface
  3. // @namespace https://greasyfork.org/en/users/668704-phuz
  4. // @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
  5. // @version 1.00
  6. // @description Fix the UR Interface
  7. // @author phuz
  8. // @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/
  9. // @require http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js
  10. // @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_info
  13. // @grant GM_fetch
  14. // @grant GM_addStyle
  15.  
  16. /* global OpenLayers */
  17. /* global W */
  18. /* global WazeWrap */
  19. /* global $ */
  20. /* global I18n */
  21. /* global _ */
  22. /* global MutationObserver */
  23.  
  24. // ==/UserScript==
  25.  
  26.  
  27. //Begin script function
  28. (function () {
  29. 'use strict';
  30. //Bootstrap
  31. window["text123"] = 123;
  32. function bootstrap(tries = 1) {
  33. if (W && W.loginManager && W.map && W.loginManager.user && W.model
  34. && W.model.states && W.model.states.getObjectArray().length && WazeWrap && WazeWrap.Ready) {
  35. if (!OpenLayers.Icon) {
  36.  
  37. }
  38. } else if (tries < 1000) {
  39. setTimeout(function () { bootstrap(++tries); }, 200);
  40. }
  41. }
  42.  
  43. bootstrap();
  44.  
  45. function loadObserver() {
  46. console.log("here we go...");
  47. const element = document.getElementById("panel-container");
  48. const observer = new MutationObserver((mutations) => {
  49. mutations.forEach((mutation) => {
  50. const { target } = mutation;
  51. if (mutation.attributeName === 'class') {
  52. let intervalID = setInterval(function () {
  53. if (document.getElementsByClassName("comment-list")[0]) {
  54. let commentList = document.getElementsByClassName("comment-list");
  55. commentList[0].remove(); //style = "display: none;";
  56. clearInterval(intervalID);
  57. fixTheBox();
  58. $('#panel-container .mapUpdateRequest .top-section .body .conversation .new-comment-form .send-button').on('click', () => { fixTheBox(); });
  59. }
  60. }, 50);
  61. }
  62. });
  63. });
  64.  
  65. observer.observe(element, { subtree: true, childList: true, attributes: true });
  66. }
  67. setTimeout(function () {
  68. loadObserver();
  69. }, 2000);
  70.  
  71. function fixTheBox() {
  72. let reports = document.getElementsByClassName("map-problem");
  73. for (i = 0; i < reports.length; i++) {
  74. if (reports[i].classList.contains("selected")) {
  75. let reportID = (reports[i].getAttribute("data-id"));
  76. var newDiv = document.createElement("div");
  77. newDiv.id = "phuzReportComments";
  78. if (document.getElementById("phuzReportComments")) {
  79. document.getElementById("phuzReportComments").remove();
  80. }
  81. document.getElementsByClassName("conversation-view")[0].prepend(newDiv);
  82. GM_xmlhttpRequest({
  83. method: "GET",
  84. url: "https://www.waze.com/Descartes/app/MapProblems/UpdateRequests?ids=" + reportID,
  85. onload: function (response) {
  86. let result = JSON.parse(response.responseText);
  87. let responder = [];
  88. if (result.users.objects.length > 0) {
  89. for (i = 0; i < result.users.objects.length; i++) {
  90. responder.push({ id: result.users.objects[i].id, user: result.users.objects[i].userName, rank: result.users.objects[i].rank + 1 });
  91. }
  92. }
  93. let divHTML = "";
  94. let commentUser;
  95. for (i = 0; i < result.updateRequestSessions.objects[0].comments.length; i++) {
  96. if (result.updateRequestSessions.objects[0].comments[i].userID == -1) {
  97. commentUser = "<font color=#26bae8>Reporter</font>";
  98. } else {
  99. for (j = 0; j < result.users.objects.length; j++) {
  100. if (result.updateRequestSessions.objects[0].comments[i].userID == result.users.objects[j].id) {
  101. commentUser = result.users.objects[j].userName + "(" + (result.users.objects[j].rank + 1) + ")";
  102. }
  103. }
  104. }
  105. divHTML += "<table border=0 width=100% cellpadding=1 cellspacing=1>";
  106. divHTML += "<tr><td><b>" + commentUser + "</b></td><td align=right style='font-size: 11px;'>" + moment(new Date(result.updateRequestSessions.objects[0].comments[i].createdOn)).format('LLL') + "</td></tr>";
  107. divHTML += "<tr><td colspan=2>" + result.updateRequestSessions.objects[0].comments[i].text + "</td></tr>";
  108. divHTML += "<hr style='margin: 5px;'>";
  109. }
  110. divHTML += "</table>";
  111. divHTML += "<hr style='margin: 5px;'>";
  112. document.getElementById("phuzReportComments").innerHTML = divHTML;
  113. }
  114. });
  115. }
  116. }
  117. }
  118.  
  119. })();