WME Auto Reload

Auto-reloads the WME data model on map moves

  1. // ==UserScript==
  2. // @name WME Auto Reload
  3. // @namespace http://greasemonkey.chizzum.com
  4. // @description Auto-reloads the WME data model on map moves
  5. // @include https://*.waze.com/*editor*
  6. // @include https://editor-beta.waze.com/*
  7. // @include https://beta.waze.com/*
  8. // @exclude https://www.waze.com/user/*editor/*
  9. // @exclude https://www.waze.com/*/user/*editor/*
  10. // @grant none
  11. // @version 1.1
  12. // ==/UserScript==
  13.  
  14. /* JSHint Directives */
  15. /* globals W: true */
  16. /* jshint bitwise: false */
  17. /* jshint eqnull: true */
  18. /* jshint esversion: 6 */
  19.  
  20. function warReload()
  21. {
  22. var inhibitReload = false;
  23. inhibitReload = inhibitReload || (document.getElementsByClassName("waze-icon-save ItemDisabled").length == 0);
  24. inhibitReload = inhibitReload || W.selectionManager.hasSelectedFeatures();
  25. if(inhibitReload === false)
  26. {
  27. W.controller.reload();
  28. }
  29. }
  30. function warInit()
  31. {
  32. if(document.location.href.indexOf('user') !== -1)
  33. {
  34. return;
  35. }
  36. if(typeof W != "undefined")
  37. {
  38. if((typeof W.controller != "undefined") && (typeof W.selectionManager != "undefined") && (typeof W.map != "undefined"))
  39. {
  40. W.map.events.register("moveend", null, warReload);
  41. return;
  42. }
  43. }
  44. window.setTimeout(warInit,250);
  45. }
  46. warInit();