WazeWrap

A base library for WME script writers

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/24851/1558013/WazeWrap.js

  1. // ==UserScript==
  2. // @name WazeWrap
  3. // @namespace https://greatest.deepsurf.us/users/30701-justins83-waze
  4. // @version 2025.03.22.00
  5. // @description A base library for WME script writers
  6. // @author JustinS83/MapOMatic
  7. // @include https://beta.waze.com/*editor*
  8. // @include https://www.waze.com/*editor*
  9. // @exclude https://www.waze.com/*user/editor/*
  10. // @grant GM_xmlhttpRequest
  11. // ==/UserScript==
  12.  
  13. /* global WazeWrap */
  14. /* global $ */
  15. /* jshint esversion:6 */
  16.  
  17. var WazeWrap = {};
  18.  
  19. (function() {
  20. 'use strict';
  21. const MIN_VERSION = '2019.05.01.01';
  22. // const WW_URL = 'https://cdn.jsdelivr.net/gh/WazeDev/WazeWrap@latest/WazeWrapLib.js'; //'https://cdn.staticaly.com/gh/WazeDev/WazeWrap/master/WazeWrapLib.js?env=dev';
  23. const WW_URL = 'https://wazedev.github.io/WazeWrap/WazeWrapLib.js';
  24.  
  25. async function init(){
  26. const sandboxed = typeof unsafeWindow !== 'undefined';
  27. const pageWindow = sandboxed ? unsafeWindow : window;
  28. const wwAvailable = pageWindow.WazeWrap && (!pageWindow.WazeWrap.Version || pageWindow.WazeWrap.Version > MIN_VERSION);
  29.  
  30. if (wwAvailable) {
  31. WazeWrap = pageWindow.WazeWrap;
  32. } else {
  33. pageWindow.WazeWrap = WazeWrap;
  34. }
  35. if (sandboxed) window.WazeWrap = WazeWrap;
  36. if (!wwAvailable) await $.getScript(WW_URL);
  37. }
  38. function bootstrap(tries = 1) {
  39. if (typeof $ != 'undefined')
  40. init();
  41. else if (tries < 1000)
  42. setTimeout(function () { bootstrap(tries++); }, 100);
  43. else
  44. console.log('WazeWrap launcher failed to load');
  45. }
  46. bootstrap();
  47. })();