From 88c6d4cdc68d50377982937a526c037b8ee161e0 Mon Sep 17 00:00:00 2001 From: Mikhail Veygman Date: Sat, 28 Jun 2025 13:30:45 -0400 Subject: [PATCH 1/4] Store Git Ignore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fed401d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +package-lock.json +node_modules/ \ No newline at end of file From aeeedf49b0593bfedf3fd72a966d47578e658e8a Mon Sep 17 00:00:00 2001 From: Mikhail Veygman Date: Sat, 28 Jun 2025 13:40:35 -0400 Subject: [PATCH 2/4] Fix waiting. --- WMEPIE.js | 86 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/WMEPIE.js b/WMEPIE.js index 730f554..75fca1c 100644 --- a/WMEPIE.js +++ b/WMEPIE.js @@ -1,7 +1,7 @@ // ==UserScript== // @name WME Place Interface Enhancements // @namespace https://greasyfork.org/users/30701-justins83-waze -// @version 2025.04.10.00 +// @version 2024.06.28.001 // @description Enhancements to various Place interfaces // @include https://www.waze.com/editor* // @include https://www.waze.com/*/editor* @@ -878,6 +878,47 @@ var UpdateObject, MultiAction; } + // Function used in LaneTools. + // Waiting for Element to Be Loaded, which is necessary due to shadowRoot delayed rendering. + function waitForElementLoaded(selector, root = undefined) { + return new Promise((resolve) => { + if (!root) { + if (document.querySelector(selector)) { + return resolve(document.querySelector(selector)); + } + + const observer = new MutationObserver((mutations) => { + if (document.querySelector(selector)) { + observer.disconnect(); + resolve(document.querySelector(selector)); + } + }); + + observer.observe(document.body, { + childList: true, + subtree: true, + }); + } else { + if (root.querySelector(selector)) { + return resolve(root.querySelector(selector)); + } + + const observer = new MutationObserver((mutations) => { + if (root.querySelector(selector)) { + observer.disconnect(); + resolve(root.querySelector(selector)); + } + }); + + observer.observe(root, { + childList: true, + subtree: true, + }); + } + }); + } + + function SetupPhotoViewer(){ //Black background let mainDiv=document.createElement('div'); @@ -3142,27 +3183,28 @@ var UpdateObject, MultiAction; // } // } -function AddMakePrimaryButtons(){ - if(!WazeWrap.hasPlaceSelected() || ($('.alias-item-content').length = 0)){ - return; - } - $('.alias-item').each(function(){ - let altItem = $(this); - if($(altItem).find('.makePrimary').length == 0){ - let $button = $('
', {class:'makePrimary alias-item-action'}).text("To Name").click(function(){ - let obj = WazeWrap.getSelectedFeatures()[0].WW.getObjectModel(); - let toPrimary = $(altItem).find('.alias-item-content').text(); - let aliases = obj.attributes.aliases.filter(a => a != toPrimary); - aliases.push(obj.attributes.name); - - let multiaction = new MultiAction(); - multiaction.doSubAction(W.model, new UpdateObject(obj, {aliases})); - multiaction.doSubAction(W.model, new UpdateObject(obj, {name: toPrimary})); - W.model.actionManager.add(multiaction); - }); - $(altItem).find('.alias-item-actions').append($button); - } - }); + function AddMakePrimaryButtons(){ + if(WazeWrap.hasPlaceSelected()){ + waitForElementLoaded(".alias-item").then(() => { + $('.alias-item').each(function(){ + let altItem = $(this); + if($(altItem).find('.makePrimary').length == 0){ + let $button = $('
', {class:'makePrimary alias-item-action'}).text("To Name").on("click", function(){ + let obj = WazeWrap.getSelectedFeatures()[0].WW.getObjectModel(); + let toPrimary = $(altItem).find('.alias-item-content').text(); + let aliases = obj.attributes.aliases.filter(a => a != toPrimary); + aliases.push(obj.attributes.name); + + let multiaction = new MultiAction(); + multiaction.doSubAction(W.model, new UpdateObject(obj, {aliases})); + multiaction.doSubAction(W.model, new UpdateObject(obj, {name: toPrimary})); + W.model.actionManager.add(multiaction); + }); + $(altItem).find('.alias-item-actions').append($button); + } + }); + }); + } } async function AddPlaceCategoriesButtons(){ From d1b7c3e33beaa0f747fc3b41263ca7a2fb8351db Mon Sep 17 00:00:00 2001 From: Mikhail Veygman Date: Sat, 28 Jun 2025 15:39:46 -0400 Subject: [PATCH 3/4] Add .Gitignore. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fed401d..220cbc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ package-lock.json -node_modules/ \ No newline at end of file +node_modules/ +.idea/ \ No newline at end of file From a647f08e1dc8d1612ede9fb80631515df619cca6 Mon Sep 17 00:00:00 2001 From: Mikhail Veygman Date: Sat, 28 Jun 2025 16:44:31 -0400 Subject: [PATCH 4/4] Commit Rendering of Copy Button. --- WMEPIE.js | 152 +++++++++++++++++++++++++++--------------------------- 1 file changed, 77 insertions(+), 75 deletions(-) diff --git a/WMEPIE.js b/WMEPIE.js index 75fca1c..1cd1fd5 100644 --- a/WMEPIE.js +++ b/WMEPIE.js @@ -3051,90 +3051,92 @@ var UpdateObject, MultiAction; var $PlaceCopyButton; if(!_.includes(WazeWrap.getSelectedFeatures()[0].WW.getObjectModel().attributes.categories,"RESIDENCE_HOME")){ $PlaceCopyButton = $('
'); - $('#venue-edit-general wz-text-input[name="name"]').before($PlaceCopyButton); - - $('#pieCopyPlaceButton').click(function(){ - var PlaceObject = require("Waze/Feature/Vector/Landmark"); - var AddPlace = require("Waze/Action/AddLandmark"); - - var oldPlace = WazeWrap.getSelectedFeatures()[0].WW.getObjectModel(); - var NewPlace = new PlaceObject({ geoJSONGeometry: W.userscripts.toGeoJSONGeometry(oldPlace.getOLGeometry().clone()) }); - - NewPlace.attributes.name = oldPlace.attributes.name + " (copy)"; - NewPlace.attributes.phone = oldPlace.attributes.phone; - NewPlace.attributes.url = oldPlace.attributes.url; - NewPlace.attributes.categories = [].concat(oldPlace.attributes.categories); - NewPlace.attributes.aliases = [].concat(oldPlace.attributes.aliases); - NewPlace.attributes.description = oldPlace.attributes.description; - NewPlace.attributes.houseNumber = oldPlace.attributes.houseNumber; - NewPlace.attributes.lockRank = oldPlace.attributes.lockRank; - - let convertedCoords; - if(oldPlace.getOLGeometry().toString().match(/^POLYGON/)){ - for(var i=0; i{ + $('#venue-edit-general wz-text-input[name="name"]').before($PlaceCopyButton); + + $('#pieCopyPlaceButton').click(function(){ + var PlaceObject = require("Waze/Feature/Vector/Landmark"); + var AddPlace = require("Waze/Action/AddLandmark"); + + var oldPlace = WazeWrap.getSelectedFeatures()[0].WW.getObjectModel(); + var NewPlace = new PlaceObject({ geoJSONGeometry: W.userscripts.toGeoJSONGeometry(oldPlace.getOLGeometry().clone()) }); + + NewPlace.attributes.name = oldPlace.attributes.name + " (copy)"; + NewPlace.attributes.phone = oldPlace.attributes.phone; + NewPlace.attributes.url = oldPlace.attributes.url; + NewPlace.attributes.categories = [].concat(oldPlace.attributes.categories); + NewPlace.attributes.aliases = [].concat(oldPlace.attributes.aliases); + NewPlace.attributes.description = oldPlace.attributes.description; + NewPlace.attributes.houseNumber = oldPlace.attributes.houseNumber; + NewPlace.attributes.lockRank = oldPlace.attributes.lockRank; + + let convertedCoords; + if(oldPlace.getOLGeometry().toString().match(/^POLYGON/)){ + for(var i=0; i