WME Copy Venue Attributes

Select a model, copy, select a poi, paste

  1. // ==UserScript==
  2. // @name WME Copy Venue Attributes
  3. // @namespace none
  4. // @description Select a model, copy, select a poi, paste
  5. // @include https://www.waze.com/editor*
  6. // @include https://www.waze.com/*/editor*
  7. // @include https://beta.waze.com/editor*
  8. // @include https://beta.waze.com/*/editor*
  9. // @exclude https://www.waze.com/*user/editor/*
  10. // @version 0.2
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var PoiAttr={};
  17. function init(){
  18. console.log("Copy Venue Attributes: INIT");
  19. var editpanel = $('#edit-panel');
  20. if (editpanel.length==0) { window.setTimeout(init, 1000); return; }
  21.  
  22. $('#edit-panel').bind('DOMSubtreeModified',function(e){
  23. var editLM = $('.geometry-button-region');
  24. if (editLM.length==1) {
  25. var copyattribDiv = $('#wme-copyattrib-fr');
  26. if (copyattribDiv.length==0) {
  27. copyattribDiv=document.createElement('div');
  28. copyattribDiv.id='wme-copyattrib-fr';
  29. $(copyattribDiv).css({'float':'right','padding':'2px','border-radius':'5px','background-color':'#fff','box-shadow':'rgba(0, 0, 0, 0.1) 0px 1px 6px 0px'});
  30. editLM[0].parentNode.insertBefore(copyattribDiv, editLM[0].nextSibling);
  31.  
  32. var copyBtn=document.createElement('span');
  33. copyBtn.innerHTML='<i class="fa fa-copy" data-original-title="" title="Copy attributes"></i>';
  34. copyBtn.style.margin='0 3px';
  35. copyBtn.onclick=CopyAttrib;
  36. copyattribDiv.appendChild(copyBtn);
  37.  
  38. var pasteBtn=document.createElement('span');
  39. pasteBtn.innerHTML='<i class="fa fa-paste" data-original-title="" title="Paste attributes"></i>';
  40. pasteBtn.style.margin='0 3px';
  41. pasteBtn.onclick=PasteAttrib;
  42. copyattribDiv.appendChild(pasteBtn);
  43. }
  44. }
  45.  
  46. })
  47. }
  48. function CopyAttrib(){
  49. $('#wme-copyattrib-fr')[0].style.backgroundColor='#26bae8';
  50. var venue=W.selectionManager.getSelectedFeatures()[0].model.attributes;
  51. PoiAttr.aliases=venue.aliases;
  52. PoiAttr.brand=venue.brand;
  53. PoiAttr.categories=venue.categories;
  54. PoiAttr.categoryAttributes=venue.categoryAttributes;
  55. PoiAttr.description=venue.description;
  56. PoiAttr.name=venue.name;
  57. PoiAttr.openingHours=venue.openingHours;
  58. PoiAttr.phone=venue.phone;
  59. PoiAttr.services=venue.services;
  60. PoiAttr.url=venue.url
  61. }
  62. function PasteAttrib(){
  63. if (Object.keys(PoiAttr).length !=0) {
  64. $('#wme-copyattrib-fr')[0].style.backgroundColor='#00aa00';
  65. try {
  66. var venue=W.selectionManager.getSelectedFeatures()[0].model;
  67. W.model.actionManager.add(new (require("Waze/Action/UpdateObject"))(venue, PoiAttr));
  68. setTimeout(function () { $('#wme-copyattrib-fr')[0].style.backgroundColor='#26bae8'; }, 1000);
  69. }
  70. catch (err) {
  71. console.log("Copy Venue Attributes : Problem", err);
  72. }
  73. }
  74. }
  75. setTimeout(init, 200);
  76. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址