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 Reply
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.

Upcoming issues in Firefox 57 and GreaseMonkey 4.0 (Nov 14!)

Post by Glodenox
Hey everybody!

I only just now noticed that GreaseMonkey 4.0 that will be enabled on Firefox 57 (to be released November 14th already!) will have various backwards-incompatible changes. With the new extensions framework in Firefox, the authors of GreaseMonkey claim to be unable to provide some of the old functionality + they want to take this opportunity to fix some of the API. Below you can find a list of changes and at the bottom you can find several solutions.

I'm not a script author, what does this mean for me?
As of November 14, you'll most likely receive the Firefox 57 update. As of that point GreaseMonkey will not be able to run most of your userscripts. Therefore it is advisable to install TamperMonkey on Firefox instead and carry over all your userscripts one by one.

What will be changed?
Several changes to the API: while some objects will remain available for a while as they are, they are considered deprecated and might not work in a new version.
All the GM_* functions have been moved to a GM object (see the API). GM_info, for example, will be available under GM.info. Some functions also changed slightly, such as GM_xmlhttpRequest which became GM.xmlHttpRequest and GM_getResourceURL became GM.getResourceUrl.
Also, several methods will now return promises instead of direct results. This makes doing some things quite a bit more complicated...

Global variables won't be available from the script any more. Pretty much all our scripts will break on this! If you want to access the Waze or OpenLayers variables, you'll need to use unsafeWindow.Waze instead. This also works in TamperMonkey, in case you were wondering. Also, this means that if you provide an object or function as parameter in a function of the page, you will need to transform it with the cloneInto or exportFunction (see more about this at the bottom of the post).

Solutions
TamperMonkey works fine on Firefox 57, so this seems like our best bet. This is something all users will have to do though and the switch isn't too easy to make as you'll need to install each userscript from the start again. Luckily most userscripts use localStorage for storing their data, so those userscripts will work exactly the same in TamperMonkey.

If you want to get your script to work on GreaseMonkey 4.0 as well, you'll need to make various changes that are not always as easy to make. These require a good knowledge of JavaScript and an understanding on how the different executions contexts work within Firefox.
I've listed the most important code changes here:

Access global variables through unsafeWindow
If you use the OL, Waze, I18n or another global variable from the WME, you'll need to retrieve them from the unsafeWindow object like so:

Code: Select all

unsafeWindow.Waze
As this would require changing your script a lot, I'd advice you to add a line like below at the top of your script:

Code: Select all

var OL = unsafeWindow.OL;
Clone/export your objects and functions you use in global functions
If you were to, for example, add a function to be called on a certain event with a call to the setEventListener of an element, you'll need to export that function to the unsafeWindow environment. Otherwise the object will attempt to call a function that is in the context of the userscript, which will throw a security violation error. This also applies for objects, though GreaseMonkey usually manages to clone easy objects automatically.
This can be done as such:

Code: Select all

// using a function as parameter
document.getElementById('someButton')
  .addEventListener('click', exportFunction(someFunction, unsafeWindow));
// using an object as parameter
unsafeWindow.$(element).tooltip(cloneInto({
  trigger: 'hover'
}, unsafeWindow));
Call the new API methods instead of the old ones
The problem with this is that TamperMonkey and others don't necessarily support this new API. A solution proposed by GreaseMonkey is to use this polyfill (a piece of JavaScript code that emulates the new API with the old functions) and switch over to the new API. I'd generally advice against using these functions too much anyway as you tend not to really need them. At this point I'd prefer to await what the TamperMonkey team is going to do.


It can be done as I have a very complex userscript that worked just fine in the new version, but it is a lot of work, which probably isn't worth it now that TamperMonkey also works on Firefox.
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1569
Answers: 1
Answers: 1
Has thanked: 278 times
Been thanked: 946 times

POSTER_ID:17118915

1

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
If you want to export your GreaseMonkey scripts to move to TamperMonkey, you can do the following:
Note: you will need to have a ZIP-manager installed like 7Zip or WinRar to create a zip archive.
  1. Go to the page "about:support" in Firefox and click the "Open Folder" button next to "Profile Folder". This will open file explorer to the profile folder of Firefox.
  2. Open the gm_scripts directory, use the search function to search for ".user.js"
  3. Select all files (Ctrl+A), right-click and create a ZIP archive of all these files
  4. Install and open TamperMonkey in Firefox, go to the Dashboard, then the Utilities tab
  5. Import the zip file you just exported and press the "import" button to confirm
  6. Go through the list of imported userscripts: go to their GreasyFork page and reinstall them. This is important to let TamperMonkey know where it can get updates. Otherwise your scripts will never receive any updates. You can see which userscripts need to be done by looking at the version number. If it is in italic and gray TamperMonkey doesn't know where to pull a new version from.
  7. Disable or uninstall GreaseMonkey
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1569
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 Twister-UK
The more I learn about FF57, the less inclined I become to allow the upgrade to occur, except perhaps in a VM that I can happily nuke and rebuild as required...
Twister-UK
Waze Local Champs
Waze Local Champs
Posts: 4705
Answers: 2
Has thanked: 745 times
Been thanked: 4748 times
Send a message
Chris (not to be confused with Chris or Chris, or even Tim, Stu, or any of the other champs team...)
AM SE England & Shetland Islands, UK Local Champ, WME Beta Tester & ScriptMangler
WME/Livemap enhancement scripts @ GreasyFork


https://chizzum.com/greasemonkey/images/beta.pnghttps://chizzum.com/greasemonkey/images/s0400.pnghttps://chizzum.com/greasemonkey/images/c5s.png

Post by Twister-UK
Be warned, even if you've told FF NOT to auto-update, chances are it'll just ignore your wishes and do so anyway :evil: :evil:
Twister-UK
Waze Local Champs
Waze Local Champs
Posts: 4705
Answers: 2
Has thanked: 745 times
Been thanked: 4748 times
Send a message
Chris (not to be confused with Chris or Chris, or even Tim, Stu, or any of the other champs team...)
AM SE England & Shetland Islands, UK Local Champ, WME Beta Tester & ScriptMangler
WME/Livemap enhancement scripts @ GreasyFork


https://chizzum.com/greasemonkey/images/beta.pnghttps://chizzum.com/greasemonkey/images/s0400.pnghttps://chizzum.com/greasemonkey/images/c5s.png