[Script] WME Keep My Layers

Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

Moderators: Unholy, bextein

Forum rules
Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

DO NOT START a new thread unless it is about a new idea. Keep discussion of existing tools within the main thread for that tool.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

[Script] WME Keep My Layers

Postby TheLastTaterTot » Sat Jan 02, 2016 5:29 am

Hi everyone, I've scripted up an add-on that automatically (or manually) resets your layers in WME to your preferred setting. The layers include ones that are not typically saved by WME (though not yet residential places nor closed URs & MPs... but soon).

As of version 0.2 (Beta), the feature list includes:
  • Saving of your preferred layers setting
  • Automatic or manual (magic wand icon) reset of layers
  • Ignore switching off of the layer if the PL links to a UR, MP, Place, Camera, or Junction Box.
  • A (presently buggy) toggler (eye icon) to review layers that were removed from a permalink
  • A WME Beta/Production Editor toggler in the left sidepanel that forces all permalinks to be loaded in Beta or Prod.
  • Removes any language specifications in a permalink
  • Darkens the Cities layer polygon so they can be seen against the satellite image
  • Makes the Area Managers polygon more see-through, which is necessary to be able to see the map underneath in areas with several AMs
  • Adjusts the Roads layer to be slightly translucent so that the actual road in the satellite image underneath can be seen without needing to toggle on/off.

As this is very much still in beta, bug reports and suggestions are welcomed and appreciated!

https://greasyfork.org/en/scripts/15698 ... -my-layers
Attachments
WMEKML v0.2.png
(175.64 KiB) Downloaded 5144 times
Last edited by TheLastTaterTot on Sat Jan 02, 2016 5:55 pm, edited 1 time in total.
R5 | RI SM | CA, MA & NY AM | Mentor
TheLastTaterTot
Wiki Master
Wiki Master
 
Posts: 480
Joined: Sat Feb 21, 2015 6:46 am
Location: RI, USA
Has thanked: 300 times
Been thanked: 316 times

Re: [Script] WME Keep My Layers

Postby tonestertm » Sat Jan 02, 2016 8:21 am

Without even looking (yet) I can tell this is going to be an immense help. :)
If I'm not mistaken, I think it's important to note that this intercepts PLs as they're initially loading: this differs from the other recent Layer reset, which completely reloads a tab after it's already opened in WME. RIght?

One suggested option -- Keep UR layer: If a &mapUpdateRequest is found in the PL, it would automagically keep, or turn, the UR layer on, regardless of the favored / current layers.
[ img ]
ARC for SW Region, USA
US Local Champ, US Country Manager
The best editors Read the Wiki and read it often. Learn the proper way to handle URs. Don't draw another Place until you read this!
tonestertm
US Waze Champs
US Waze Champs
 
Posts: 1253
Joined: Wed Nov 14, 2012 12:02 pm
Location: City of...um, Angels, CA, USA
Has thanked: 510 times
Been thanked: 859 times

Re: [Script] WME Keep My Layers

Postby AndyLaode » Sat Jan 02, 2016 9:38 am

wonderful teacher. thanks for your beautiful work
andylaode (andylaode@outlook.com)
okay, mate, see you on the road and on the map too, cheers
AndyLaode
Waze Local Champs
Waze Local Champs
 
Posts: 754
Joined: Mon May 19, 2014 9:04 am
Location: on my way from my house to insanity
Has thanked: 13 times
Been thanked: 246 times

Re: [Script] WME Keep My Layers

Postby TheLastTaterTot » Sat Jan 02, 2016 5:49 pm

tonestertm wrote:Without even looking (yet) I can tell this is going to be an immense help. :)
If I'm not mistaken, I think it's important to note that this intercepts PLs as they're initially loading: this differs from the other recent Layer reset, which completely reloads a tab after it's already opened in WME. RIght?

One suggested option -- Keep UR layer: If a &mapUpdateRequest is found in the PL, it would automagically keep, or turn, the UR layer on, regardless of the favored / current layers.


Oh! I totally forgot to mention that.. Yes, that feature has been included in this version as well. Thanks for reminding me! The script will ignore switching off of that layer if it is part of the PL. Currently this is true for the following: URs, MPs, Places, Cameras, Big Junctions.

Re the difference among existing methods--- As far as I know, there are currently two main scripts available: (1) Iainhouse's bookmarklet and (2) Vaindil's WME Layers Link Remover.

As advertised, the bookmarklet is useful for whenever you need to reset your layers to your preferred setting, regardless of whether you had changed the layers yourself or you had clicked a PL infected by &layers=. However, the bookmarklet cannot intercept the URL and it relies on how quickly the user can manually activate the bookmarklet.

Within the last month or couple months, Vaindil has updated his layers remover script so that it is now 100% successful at catching PLs with layers and redirecting (technically "replace()") the URL with one without &layers=. This is achieved upon startup of loading the main page contents (with onload()) and then stopping its process before the map loads. If he wanted to optimize his script even more, he could use a DOMContentLoaded event listener instead, which will start execution of the script even sooner. However, with a fast connection and modern computer, this difference is practically imperceptible. I would recommend his script over mine if all you are looking for is removal of &layers= from PLs. The downside is that it does not actually reset your layers, and WME will load whatever layers that are saved from a previous WME session.

WME Keep My Layers addresses the limitations of both these methods and includes some bonuses as well. While the language and beta/production-editor interceptors work similarly to Vaindil's script (albeit at DOMContentLoaded), the removal of layers is slightly delayed because it checks for layers than cannot be specified with the &layers= query. However, if there's demand for it, I can also add the option to use the faster interception method for basic layers.

HTH!
R5 | RI SM | CA, MA & NY AM | Mentor
TheLastTaterTot
Wiki Master
Wiki Master
 
Posts: 480
Joined: Sat Feb 21, 2015 6:46 am
Location: RI, USA
Has thanked: 300 times
Been thanked: 316 times

Re: [Script] WME Keep My Layers

Postby TheLastTaterTot » Sun Jan 03, 2016 12:05 am

I forgot to note that the resetting of layers is delayed, but does not redirect, so it only loads that one page. KML will either interject early and replace the settings before Waze loads them, or toggle them off immediately. Its success in achieving the former currently depends a lot on connection/computer speed and the other scripts that are also loading in parallel. That said, I'm working on optimizing it so that it will be able to replace the settings early for the majority of situations.
R5 | RI SM | CA, MA & NY AM | Mentor
TheLastTaterTot
Wiki Master
Wiki Master
 
Posts: 480
Joined: Sat Feb 21, 2015 6:46 am
Location: RI, USA
Has thanked: 300 times
Been thanked: 316 times

Re: [Script] WME Keep My Layers

Postby KuniaKid » Sun Jan 03, 2016 12:23 am

I notice that the switch on the panel is in the same spot as the Panel Swap script's icon. Although Panel Swap is currently not working for me.
KuniaKid
State Manager
State Manager
 
Posts: 418
Joined: Sun Oct 06, 2013 8:18 pm
Location: Royal Kunia, HI
Has thanked: 180 times
Been thanked: 122 times

Re: [Script] WME Keep My Layers

Postby tenetienne » Sun Jan 03, 2016 4:38 am

I usually run Firefox, currently 43.0.3, with Greasemonkey. I just loaded KML and didn't see the toggle to be able to use it, so I unloaded all my scripts to start from scratch.
After doing that, I finally found KML, of all places, at the bottom of my layers column. The problem is that the only component I can get any reaction from is the Save Selected Layers. The others, Reshow removed layers (buggy), Apply Keep My Layers and KML Settings don't react when I click on them.
I tried sending a screenshot, but Preview gave me the message "Sorry, the board attachment quota has been reached." It was only a 234K PNG file.

Massachusetts L2 editor
tenetienne
Area Manager
Area Manager
 
Posts: 81
Joined: Tue Jun 30, 2015 4:58 pm
Location: Marlborough, MA
Has thanked: 90 times
Been thanked: 20 times

Re: [Script] WME Keep My Layers

Postby TheLastTaterTot » Sun Jan 03, 2016 9:00 am

KuniaKid wrote:I notice that the switch on the panel is in the same spot as the Panel Swap script's icon. Although Panel Swap is currently not working for me.


The panel swap only shows up when you click a segment or any other map feature. The Beta toggle only shows in the user info panel, but now I realize that the panel swap remains when toggling between panels, which causes an interference btwn the two. In the next revision, I'll have the beta toggler only show when nothing is selected.
Last edited by TheLastTaterTot on Sun Jan 03, 2016 9:08 am, edited 1 time in total.
R5 | RI SM | CA, MA & NY AM | Mentor
TheLastTaterTot
Wiki Master
Wiki Master
 
Posts: 480
Joined: Sat Feb 21, 2015 6:46 am
Location: RI, USA
Has thanked: 300 times
Been thanked: 316 times

Re: [Script] WME Keep My Layers

Postby TheLastTaterTot » Sun Jan 03, 2016 9:02 am

tenetienne wrote:I usually run Firefox, currently 43.0.3, with Greasemonkey. I just loaded KML and didn't see the toggle to be able to use it, so I unloaded all my scripts to start from scratch.
After doing that, I finally found KML, of all places, at the bottom of my layers column. The problem is that the only component I can get any reaction from is the Save Selected Layers. The others, Reshow removed layers (buggy), Apply Keep My Layers and KML Settings don't react when I click on them.
I tried sending a screenshot, but Preview gave me the message "Sorry, the board attachment quota has been reached." It was only a 234K PNG file.

Massachusetts L2 editor


I don't use firefox, so let's take this to a private HO and see what could be wrong.
R5 | RI SM | CA, MA & NY AM | Mentor
TheLastTaterTot
Wiki Master
Wiki Master
 
Posts: 480
Joined: Sat Feb 21, 2015 6:46 am
Location: RI, USA
Has thanked: 300 times
Been thanked: 316 times

Re: [Script] WME Keep My Layers

Postby Glodenox » Sun Jan 03, 2016 10:22 am

On Firefox 44b4 (beta) the script causes WME to no longer load. I get a white window, but I can still hover over the SVG elements of the map and see them being highlighted (streets, nodes, ...).
The issue at hand is that the script stops working when the bootstrap function is called as Firefox 44 no longer allows any assignment of unsafeWindow (it's a constant with an undefined value).
As I've posted in several other topics by now (I'll try to write up something for the wiki today): the code in the bootstrap to get an unsafeWindow no longer works anyway as Google has removed that bug.

Short answer: just remove this piece of code and the script will load:
Code: Select all
      var bGreasemonkeyServiceDefined = false;

      try {
         bGreasemonkeyServiceDefined = ("object" === typeof Components.interfaces.gmIGreasemonkeyService)
      } catch (err) { /* Ignore */ }

      if ("undefined" === typeof unsafeWindow || !bGreasemonkeyServiceDefined) {
         unsafeWindow = (function() {
            var dummyElem = document.createElement('p');
            dummyElem.setAttribute('onclick', 'return window;');
            return dummyElem.onclick();
         })();
      }

EDIT: something else I've noticed is that the @grant statements in the meta block include a @grant none. This statement prevents the other @grant rules from working. Just removing that line allowed the script to execute further. Now I've got a ReferenceError for "$" at line 569, probably because jQuery hasn't started yet at that point.
This I've fixed with this code instead of using jQuery:
Code: Select all
document.documentElement.style.visibility = "visible";

But in the end I still get a console error saying the script gives up, even though I don't see any other messages saying that the script is trying... Weird.
Glodenox
Waze Global Champs
Waze Global Champs
 
Posts: 811
Joined: Tue Aug 11, 2015 9:04 pm
Location: Belgium
Has thanked: 332 times
Been thanked: 950 times

Next

Return to Addons, Extensions, and Scripts

Who is online

Users browsing this forum: JimboBaggins1966, mudge42