Zoom Shortcuts

Adds configurable shortcuts for all zoom levels

目前为 2022-08-17 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Zoom Shortcuts
  3. // @namespace https://gf.qytechs.cn/users/30701-justins83-waze
  4. // @version 2022.08.17.01
  5. // @description Adds configurable shortcuts for all zoom levels
  6. // @author JustinS83
  7. // @include https://www.waze.com/editor*
  8. // @include https://www.waze.com/*/editor*
  9. // @include https://beta.waze.com/editor*
  10. // @include https://beta.waze.com/*/editor*
  11. // @exclude https://www.waze.com/*user/editor*
  12. // @grant none
  13. // @require https://gf.qytechs.cn/scripts/24851-wazewrap/code/WazeWrap.js
  14. // @contributionURL https://github.com/WazeDev/Thank-The-Authors
  15. // ==/UserScript==
  16. /* global W */
  17. /* ecmaVersion 2017 */
  18. /* global $ */
  19. /* global WazeWrap */
  20. /* eslint curly: ["warn", "multi-or-nest"] */
  21. (function() {
  22. 'use strict';
  23. var settings = {};
  24. function bootstrap(tries = 1) {
  25. if (W &&
  26. W.map &&
  27. W.model &&
  28. W.loginManager.user &&
  29. $ && WazeWrap.Ready)
  30. init();
  31. else if (tries < 1000)
  32. setTimeout(function () {bootstrap(++tries);}, 200);
  33. }
  34. bootstrap();
  35. function init(){
  36. loadSettings();
  37. new WazeWrap.Interface.Shortcut('ZoomNew10Shortcut', 'Zoom to 10', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.ZoomNew10Shortcut, function(){W.map.olMap.zoomTo(10);}, null).add();
  38. new WazeWrap.Interface.Shortcut('ZoomNew11Shortcut', 'Zoom to 11', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.ZoomNew11Shortcut, function(){W.map.olMap.zoomTo(11);}, null).add();
  39. new WazeWrap.Interface.Shortcut('Zoom0Shortcut', 'Zoom to 12 (old 0)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom0Shortcut, function(){W.map.olMap.zoomTo(0+12);}, null).add();
  40. new WazeWrap.Interface.Shortcut('Zoom1Shortcut', 'Zoom to 13 (old 1)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom1Shortcut, function(){W.map.olMap.zoomTo(1+12);}, null).add();
  41. new WazeWrap.Interface.Shortcut('Zoom2Shortcut', 'Zoom to 14 (old 2)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom2Shortcut, function(){W.map.olMap.zoomTo(2+12);}, null).add();
  42. new WazeWrap.Interface.Shortcut('Zoom3Shortcut', 'Zoom to 15 (old 3)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom3Shortcut, function(){W.map.olMap.zoomTo(3+12);}, null).add();
  43. new WazeWrap.Interface.Shortcut('Zoom4Shortcut', 'Zoom to 16 (old 4)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom4Shortcut, function(){W.map.olMap.zoomTo(4+12);}, null).add();
  44. new WazeWrap.Interface.Shortcut('Zoom5Shortcut', 'Zoom to 17 (old 5)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom5Shortcut, function(){W.map.olMap.zoomTo(5+12);}, null).add();
  45. new WazeWrap.Interface.Shortcut('Zoom6Shortcut', 'Zoom to 18 (old 6)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom6Shortcut, function(){W.map.olMap.zoomTo(6+12);}, null).add();
  46. new WazeWrap.Interface.Shortcut('Zoom7Shortcut', 'Zoom to 19 (old 7)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom7Shortcut, function(){W.map.olMap.zoomTo(7+12);}, null).add();
  47. new WazeWrap.Interface.Shortcut('Zoom8Shortcut', 'Zoom to 20 (old 8)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom8Shortcut, function(){W.map.olMap.zoomTo(8+12);}, null).add();
  48. new WazeWrap.Interface.Shortcut('Zoom9Shortcut', 'Zoom to 21 (old 9)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom9Shortcut, function(){W.map.olMap.zoomTo(9+12);}, null).add();
  49. new WazeWrap.Interface.Shortcut('Zoom10Shortcut', 'Zoom to 22 (old 10)', 'wmezoomshortcuts', 'Zoom Shortcuts', settings.Zoom10Shortcut, function(){W.map.olMap.zoomTo(10+12);}, null).add();
  50. window.addEventListener("beforeunload", function() {
  51. saveSettings();
  52. }, false);
  53. }
  54. function loadSettings() {
  55. var loadedSettings = $.parseJSON(localStorage.getItem("WMEZoomShortcuts_Settings"));
  56. var defaultSettings = {
  57. Zoom1Shortcut: '',
  58. Zoom2Shortcut: '',
  59. Zoom3Shortcut: '',
  60. Zoom4Shortcut: '',
  61. Zoom5Shortcut: '',
  62. Zoom6Shortcut: '',
  63. Zoom7Shortcut: '',
  64. Zoom8Shortcut: '',
  65. Zoom9Shortcut: '',
  66. Zoom10Shortcut: '',
  67. Zoom0Shortcut: '',
  68. ZoomNew10Shortcut: '',
  69. ZoomNew11Shortcut: ''
  70. };
  71. settings = $.extend({}, defaultSettings, loadedSettings)
  72. }
  73. function saveSettings(){
  74. if (localStorage) {
  75. var localsettings = {
  76. Zoom1Shortcut: settings.Zoom1Shortcut,
  77. Zoom2Shortcut: settings.Zoom2Shortcut,
  78. Zoom3Shortcut: settings.Zoom3Shortcut,
  79. Zoom4Shortcut: settings.Zoom4Shortcut,
  80. Zoom5Shortcut: settings.Zoom5Shortcut,
  81. Zoom6Shortcut: settings.Zoom6Shortcut,
  82. Zoom7Shortcut: settings.Zoom7Shortcut,
  83. Zoom8Shortcut: settings.Zoom8Shortcut,
  84. Zoom9Shortcut: settings.Zoom9Shortcut,
  85. Zoom10Shortcut: settings.Zoom10Shortcut,
  86. Zoom0Shortcut: settings.Zoom0Shortcut,
  87. ZoomNew10Shortcut: settings.ZoomNew10Shortcut,
  88. ZoomNew11Shortcut: settings.ZoomNew11Shortcut
  89. };
  90. for (var name in W.accelerators.Actions) {
  91. var TempKeys = "";
  92. if (W.accelerators.Actions[name].group == 'wmezoomshortcuts') {
  93. if (W.accelerators.Actions[name].shortcut) {
  94. if (W.accelerators.Actions[name].shortcut.altKey === true)
  95. TempKeys += 'A';
  96. if (W.accelerators.Actions[name].shortcut.shiftKey === true)
  97. TempKeys += 'S';
  98. if (W.accelerators.Actions[name].shortcut.ctrlKey === true)
  99. TempKeys += 'C';
  100. if (TempKeys !== "")
  101. TempKeys += '+';
  102. if (W.accelerators.Actions[name].shortcut.keyCode)
  103. TempKeys += W.accelerators.Actions[name].shortcut.keyCode;
  104. } else
  105. TempKeys = "-1";
  106. localsettings[name] = TempKeys;
  107. }
  108. }
  109. localStorage.setItem("WMEZoomShortcuts_Settings", JSON.stringify(localsettings));
  110. }
  111. }
  112. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址