Too Many Layers

Allows a longer list of layers in the map layers menu.

  1. // ==UserScript==
  2. // @name Too Many Layers
  3. // @namespace https://greasyfork.org/en/scripts/507731-too-many-layers
  4. // @version 2024.09.10.001
  5. // @description Allows a longer list of layers in the map layers menu.
  6. // @author robosphinx_, callumhume
  7. // @match *://*.waze.com/*editor*
  8. // @exclude *://*.waze.com/user/editor*
  9. // @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
  10. // @grant none
  11. // @license GPLv3
  12. // ==/UserScript==
  13.  
  14. /* global W */
  15. /* global WazeWrap */
  16.  
  17. (function main() {
  18. 'use strict';
  19.  
  20. const SCRIPT_LONG_NAME = GM_info.script.name;
  21. const SCRIPT_SHORT_NAME = "WME-TML";
  22. const SCRIPT_VERSION = GM_info.script.version;
  23.  
  24. const DISPLAY_LAYER_GROUP_CLASS = '.collapsible-GROUP_DISPLAY';
  25.  
  26. let successfulStartup = false;
  27.  
  28. function fancyLogMessage(tag, message) {
  29. if (tag == "ERROR") {
  30. console.error(SCRIPT_SHORT_NAME + ": " + tag + ": " + message);
  31. }
  32. else {
  33. console.log(SCRIPT_SHORT_NAME + ": " + tag + ": " + message);
  34. }
  35. }
  36.  
  37. function embiggenTheList() {
  38. // Heirarchy follows
  39. // ID layer-switcher-region
  40. // class layer-switcher
  41. // class menu
  42. // class scrollable
  43. // class list-unstyled togglers
  44. // class group
  45. // class collapsible-GROUP_DISPLAY
  46. try {
  47. fancyLogMessage("INFO", "Looking for display layer group...");
  48. let displayGroup = document.querySelector(DISPLAY_LAYER_GROUP_CLASS); // Grab element by class name, not ID
  49. if (displayGroup != null) {
  50. fancyLogMessage("INFO", "Found display layer group: " + displayGroup);
  51. displayGroup.style.setProperty('max-height', 'fit-content');
  52. successfulStartup = true;
  53. }
  54. else {
  55. fancyLogMessage("ERROR", "Could not find element with class " + DISPLAY_LAYER_GROUP_CLASS);
  56. successfulStartup = false;
  57. }
  58. }
  59. catch (err) {
  60. fancyLogMessage("ERROR", "Looking for display group returned error " + err);
  61. successfulStartup = false;
  62. }
  63. };
  64.  
  65.  
  66. function init() {
  67. fancyLogMessage("INFO", SCRIPT_LONG_NAME + " " + SCRIPT_VERSION + " started");
  68. embiggenTheList();
  69. if (successfulStartup) {
  70. fancyLogMessage("INFO", SCRIPT_LONG_NAME + " initialized!");
  71. }
  72. else {
  73. fancyLogMessage("ERROR", SCRIPT_LONG_NAME + " could not initialize.");
  74. }
  75. }
  76.  
  77. function onWmeReady() {
  78. if (WazeWrap && WazeWrap.Ready) {
  79. init();
  80. } else {
  81. setTimeout(onWmeReady, 100);
  82. }
  83. }
  84.  
  85. function bootstrap() {
  86. if (typeof W === 'object' && W.userscripts?.state.isReady) {
  87. onWmeReady();
  88. } else {
  89. document.addEventListener('wme-ready', onWmeReady, { once: true });
  90. }
  91. }
  92.  
  93. bootstrap();
  94. })();