Script authors: support recovering from Event Mode
Very recently the event mode has become available in the WME (might be restricted to some countries, not entirely sure). When this mode gets activated, tab(s) generated by your userscript will be removed because everything in div#sidebarContent will be cleared and replaced with the sidebar content for the event mode.
So whenever the mode is changed, you'll need to re-add your tab. The cleanest solution I could find for this is adding an event listener on the modeController, like so:
I'd suggest to just store the div in which your tab stores its data in a variable and add that div again as a tab whenever the mode is changed back.
If you wish to know which mode has become active (as your script is probably not useful within Event mode), you can check the second parameter that the event call gives (see below). Default mode = 0, Event mode = 1
The callback function for a mode change has this signature:
So whenever the mode is changed, you'll need to re-add your tab. The cleanest solution I could find for this is adding an event listener on the modeController, like so:
Code: Select all
// This assumes you have a function named init() that you want to call
Waze.app.modeController.model.bind('change:mode', init);
If you wish to know which mode has become active (as your script is probably not useful within Event mode), you can check the second parameter that the event call gives (see below). Default mode = 0, Event mode = 1
The callback function for a mode change has this signature:
Code: Select all
function(model, modeId, context?)
Re: Script authors: support recovering from Event Mode