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.
Post by doctorkb
Your script does a better job of making them obvious. :)

The layer from Waze only has little indicators.
doctorkb
Posts: 4385
Answers: 4
Has thanked: 433 times
Been thanked: 1464 times
Send a message

Post by doctorkb
LiveMap closures would be perfect.
doctorkb
Posts: 4385
Answers: 4
Has thanked: 433 times
Been thanked: 1464 times
Send a message

Post by doctorkb
pvo11 wrote:
AlanOfTheBerg wrote: Only L5+ can see the Road Closures layer. Currently, the layers look like this with Road Closures being default set to Shift+c as the shortcut:
I don't have access to the beta with my login. In the Practice mode is the layer visible but there is nothing visible in the layer.
There may be a cross-domain security issue -- with Toolbox, we can't get the inset livemap to show on beta, either.
doctorkb
Posts: 4385
Answers: 4
Has thanked: 433 times
Been thanked: 1464 times
Send a message

Post by dummyd2
since the script runs in a monkey, you can use GM_xmlhttpRequest instead of ajax method to allow cross-domain requests.
See description
dummyd2
Emeritus Local Champ
Emeritus Local Champ
Posts: 1330
Has thanked: 210 times
Been thanked: 1005 times
Send a message
Dummyd2 AKA D2.
Retired - retraité de Waze

Post by dummyd2
Yes, when you @grant something, your script is run in a sandbox, so you must use unsafeWindow to access to Waze objects.
Perhaps, in your case, there is a simplest way. Since closures are available in the WME Beta, you can detect the WME Beta, and only change the display of closures. Else, download data from livemap, like you do actually.
Well, as it has been said, it is some work for only few users ;)
dummyd2
Emeritus Local Champ
Emeritus Local Champ
Posts: 1330
Has thanked: 210 times
Been thanked: 1005 times
Send a message
Dummyd2 AKA D2.
Retired - retraité de Waze

Post by foxitrot
Excellent materialization of an idea!

Sent from a touch display, which took care of perfectly scrambling my thoughts.
foxitrot
Waze Global Champs
Waze Global Champs
Posts: 7263
Has thanked: 1283 times
Been thanked: 649 times
Send a message
...with the good old crashing :roll: Symbian 2.1.99.114 (on N-E52), while
trying to get used to the good new asocial Android 4.xx.0.yyy (on OP-X March-me-Low).

Post by Glodenox
As of a couple of weeks ago, this handy script refused to work for me. I'm running Firefox 44.0b2 and Greasemonkey 3.6.
The error messages I got in the browser console were that the Components object is no longer supported and will be removed soon and that there was an attempt to assign a value to unsafeWindow, which is a const.

As this script doesn't use unsafeWindow anywhere, this was quite easy to solve for me locally by removing everything in the bootstrap function but the setTimeout call. I've also wrapped the whole script in an anonymous function as this script exposes some functions with a name that is likely to clash with other scripts at some point (drawLine, requestClosures, changeLayer especially).
This is simple to do: just put all existing code within the function:

Code: Select all

(function() {
	//...
})();
It creates an anonymous function that hides its functions and gets executed straight away.

I've also adjusted the bootstrap as it currently fails to load if the map isn't there after waiting 3 seconds. This code checks whether the map has loaded after 500 milliseconds and keeps on trying each 500 milliseconds until the map has loaded.

Code: Select all

	function liveMapClosures_bootstrap()
	{
		if (typeof Waze === 'undefined' || typeof Waze.map === 'undefined') {
			setTimeout(liveMapClosures_bootstrap, 500);
			console.log('Waze object unavailable, map still loading');
		} else {
			liveMapClosures_init();
		}		
	}
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
pvo11 wrote:Wrapping script to an anonymous function is not necessary because this will be done by GM and the functions are not visible outside the script.
I've just tested this and it seems you are right. I assumed these functions would be exposed as the code recommendations mentioned prefixing your function names with something script-specific, but that seems to be based on the old and non-sandbox working of GreaseMonkey and therefore no longer relevant indeed.
pvo11 wrote:For the bootstrapping use the code recommended here:
https://wiki.waze.com/wiki/Scripts/WME_ ... otstraping
I'm aware of that page and have already proposed changes to it quite a while ago. I've now updated that proposal to take into account the sandboxing of variables and functions.
Any script using that will most likely end up throwing the same error in Firefox soon.
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
Just tested it and no problems found now :)

Have you been able to replicate this error yourself? I've just checked it out on my laptop (that I rarely use) and I only got the "Components object no longer supported, will be removed soon" errors in Firefox 42 and 43, but got the unsafeWindow is a const error from the moment I upgraded to the beta. Unless both my computers somehow have a weird setting that triggers this, I think this issue will be widespread once Firefox 44 arrives in Release.

I'll look around in the other scripts that seem to be quite popular so we can be proactive about this. It remains a weird error though. UnsafeWindow is undefined, but we're not allowed to define it ourselves.
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
Thanks, I had just made practically the same changes and was about to post them here :)
I did notice that the offset value you use is a bit too big. We sometimes run into the limits of how many jams get returned at the moment. Changing 'oh' from 20000 to 500 fixes that.
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png