[BOOKMARKLET] Reset Permalink layers

It’s the bane of every editors life. You follow a permalink - and your layers palette is changed to something else. So then you have to reset them all.

A very good workaround is to create a bookmark that includes only the layers parameter - e.g. waze.com/editor/?layers=1477. That will reload the editor without changing your location but with your preferred layers. However, if the original permalink you followed included selections like an MP, UR, place or segments, the selection will be lost.

So I have created the following bookmarklet. Quite simply, it replaces the layers parameter in the current URL with your preferred set of layers and reloads the page - leaving all other parameters intact.

javascript:(function(){window.location.href=window.location.href.replace(/layers=\d+/i,"layers=1477");})();

Usage is quite simple:

  • Open WME and set the layers to your desired combination
  • Hit the Permalink button in the bottom right-hand corner to reload the page
  • In the address box, look for the layers=xxxx parameter. xxxx is the number that represents your preferred layers. (my preferred combination is 1477).
  • Create a new bookmark. Call it whatever you like and set the address/URL to the code given above, but with your preferred layers. There are instructions in the Wiki here for creating bookmarks in Chrome and Firefox
    And - if you have more than one preferred set of layers (say one with & one without places turned on), you can create as many of these bookmarks as you like. :slight_smile:

Thanks for the bookmarklet, is there a way to also remove the language from the permalink?

I don’t like to receive links with /es/ /es-419/ in permalinks :?

I’m trying but seems to do something wrong.
Can you give me a example the bookmark should look like with https://www.waze.com/nl/editor/?env=row&lon=4.70659&lat=52.31230&layers=965&zoom=1 ? I’m not so familiar whit javascript.

The bookmarklet as given above seems to word fine for me with the URL you gave. If you’re having trouble creating the bookmarklet, there are instructions in the Wiki. I’ve edited the original post to include a link to those instructions. :smiley:

What it does is reload the current page after doing a simple search/replace: it searches the current URL for the string layers=# (where # is a string of numerical digits) and replaces that bit of the URL with layers=1477 (or whatever value you replaced 1477 with).

In the replace command, /layers=\d+/i is a Javascript Regular Expression which is constructed as follows:

  • / marks the start of a regexp
  • layers= matches exactly that text
  • \d matches a numerical digit
  • + says to match one or more of the previous item - in this case numerical digit.
  • / ends the pattern to be searched for
  • i is an option to say ignore case when searching - so LAYERS would be replaced as well as layers

Coding this is pretty easy, but I’m not sure if it will work or not.

To explain this, I should say I understand your problem. I never use en-gb settings. As I tend to work on a “global” basis, I prefer my WME to use global standards: Freeway not Motorway; Parking Lot Road not Car Park Road etc. So my WME language settings are set to plain “English”, rather than “English UK”.

However, when I try to load a permalink with “/en-gb/” in it, WME automatically re-loads it without that part of the URL, so I don’t get a chance to see whether my code can remove it! Because of this, I can’t test whether I can remove the language settings. If you can give me an “es” permalink I can give that a try.

In the meantime, this version should do what you need, if WME doesn’t interfere:

javascript:(function(){window.location.href=window.location.href.replace(/layers=\d+/i,"layers=1477").replace(/\/es\//i,"/").replace(/\/es\//i,"/");})();

It does what I need, I only added -419 to one of the two es :slight_smile:

Thanks a lot!

Found this and thought I would drop it here:

Thanks for all the explanations ianhouse, I had the same issue with links for WME in french. Nice tip!

Hmm… does not seem to work… I disabled some layers, pressed bookmark, and nothing changed…

I’m not sure if the problem you’re reporting is with my bookmarklet or vaindil’s script.

All my bookmarklet does is reload the current URL showing in the address box, but replacing a layers parameter (if there is one) with a fixed value. Changing layers in the editor will not have any effect, as it doesn’t change the current URL or the value the bookmarklet replaces it with.

What vaindil’s script does is different. It catches the onload event that happens when you click on a hyperlink and the window is first loaded. It strips the layer parameter from the URL (well before the editor actually loads). That causes the URL to reload: presumably after the window onload event, otherwise it would get stuck in a loop. :lol:

Modified the original bookmarklet to insert the layers argument for when I get a link with no layers, but it loads in an undesirable way. Only been in use a few days. Use it at your own risk. It depends on there being a “lat” argument in the URL.

javascript:(function(){if(window.location.href=window.location.href.indexOf('layers=')<0){window.location.href=window.location.href.replace(/(lat\=[^&]+)/i,"$1&layers=4");}else{window.location.href=window.location.href.replace(/layers=\d+/i,"layers=4");}})();

I updated the code to work with the new Permalink scheme, it is simply a matter of substituting “layers” for “s” and introducing the new numbers.

javascript:(function(){window.location.href=window.location.href.replace(/s=\d+/i,"s=#########");})();