forked from SaiCode-DEV/Waze-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWME Fix UI SaiCode Edition.user.js
More file actions
5083 lines (4883 loc) · 214 KB
/
WME Fix UI SaiCode Edition.user.js
File metadata and controls
5083 lines (4883 loc) · 214 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name WME Fix UI SaiCode Edition
// @namespace https://greasyfork.org/en/scripts/435828-wme-fix-ui-memorial-edition
// @description Allows alterations to the WME UI to fix things screwed up or ignored by Waze
// @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/
// @supportURL https://www.waze.com/forum/viewtopic.php?t=334618
// @version 1.63.257
// @grant GM_addStyle
// ==/UserScript==
/*
SaiCode Edition thanks:
SaiCode :)
Memorial Edition thanks:
phuz, fuji2086, Timbones, laurenthembprd, jm6087, BeastlyHaz
Original version thanks:
Bellhouse, Twister-UK, Timbones, Dave2084, Rickzabel, Glodenox,
JJohnston84, SAR85, Cardyin, JustinS83, berestovskyy, Sebiseba,
The_Cre8r, ABelter
=======================================================================================================================
Bug fixes - MUST BE CLEARED BEFORE RELEASE
=======================================================================================================================
*/
/* JSHint Directives */
/* globals $ */
/* globals W: true */
/* globals I18n */
/* globals OpenLayers: true */
/* globals trustedTypes */
/* globals ResizeObserver */
/* globals jQuery */
/* jshint esversion: 11 */
(function main() {
"use strict";
// global variables
const FUME_VERSION = "1.63.257";
const FUME_DATE = "2024-05-07";
const newVersionNotes = ["Compatibility fix for latest WME release..."];
const PREFIX = "WMEFUME";
const DEFAULT_OPTIONS = {
oldVersion: "0.0",
moveZoomBar: true,
shrinkTopBars: true,
restyleSidePanel: true,
restyleReports: true,
enhanceChat: true,
narrowSidePanel: false,
arialShiftX: 0,
arialShiftY: 0,
arialOpacity: 100,
arialShiftXO: 0,
arialShiftYO: 0,
arialOpacityO: 100,
fixExternalProviders: true,
GSVContrast: 100,
GSVBrightness: 100,
GSVInvert: false,
GSVWidth: 50,
restyleLayersMenu: true,
layers2Cols: false,
moveChatIcon: true,
highlightInvisible: true,
darkenSaveLayer: true,
layersMenuMore: true,
UIContrast: 1,
UICompression: 1,
swapRoadsGPS: true,
showMapBlockers: true,
tameLockedSegmentMsg: false,
hideSegmentPanelLabels: false,
tameSegmentTypeMenu: false,
tameElevationMenu: false,
removeRoutingReminder: false,
reEnableSidePanel: false,
disableBridgeButton: true,
disablePathButton: false,
ISODates: true,
mondayFirst: false,
disableKinetic: false,
disableScrollZoom: false,
disableAnimatedZoom: false,
disableUITransitions: false,
disableSaveBlocker: false,
colourBlindTurns: false,
hideMenuLabels: false,
unfloatButtons: false,
moveUserInfo: false,
hackGSVHandle: false,
enlargeGeoNodes: false,
geoNodeSize: 8,
enlargeGeoHandles: false,
geoHandleSize: 6,
enlargePointMCs: false,
pointMCScale: 1,
resizeSearchBox: false,
theme: "system",
};
let options;
const debug = true;
let wmeFUinitialising = true;
let kineticDragParams;
let yslider;
let layersButton;
let refreshButton;
let shareButton;
let zliResizeObserver = null;
let killTurnPopup = false;
let abAlerts = null;
const abAlertBoxStack = [];
let abAlertBoxTickAction = null;
let abAlertBoxCrossAction = null;
let abAlertBoxInUse = false;
function abAlertBoxObj(
headericon,
title,
content,
hasCross,
tickText,
crossText,
tickAction,
crossAction,
) {
this.headericon = headericon;
this.title = title;
this.content = content;
this.hasCross = hasCross;
this.tickText = tickText;
this.crossText = crossText;
this.tickAction = tickAction;
this.crossAction = crossAction;
}
function abCloseAlertBox() {
$("#abAlerts").fadeOut(250, () => {
document.getElementById("abAlerts").childNodes[0].innerHTML = modifyHTML("");
document.getElementById("abAlerts").childNodes[1].innerHTML = modifyHTML("");
document.getElementById("abAlertTickBtnCaption").innerHTML = modifyHTML("");
document.getElementById("abAlertCrossBtnCaption").innerHTML = modifyHTML("");
abAlertBoxTickAction = null;
abAlertBoxCrossAction = null;
$("#abAlertCrossBtn").hide();
abAlertBoxInUse = false;
if (abAlertBoxStack.length > 0) {
abBuildAlertBoxFromStack();
}
});
}
function abCloseAlertBoxWithTick() {
if (typeof abAlertBoxTickAction === "function") {
abAlertBoxTickAction();
}
abCloseAlertBox();
}
function abCloseAlertBoxWithCross() {
if (typeof abAlertBoxCrossAction === "function") {
abAlertBoxCrossAction();
}
abCloseAlertBox();
}
function abShowAlertBox(
headericon,
title,
content,
hasCross,
tickText,
crossText,
tickAction,
crossAction,
) {
abAlertBoxStack.push(
new abAlertBoxObj(
headericon,
title,
content,
hasCross,
tickText,
crossText,
tickAction,
crossAction,
),
);
if (abAlertBoxInUse === false) {
abBuildAlertBoxFromStack();
}
}
function abBuildAlertBoxFromStack() {
const tbIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAPdXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjapZhpciu7coT/YxVeAuZhORgjvAMv31+iW7Skc/xeXFuUSKrZxFCVlZkFs//rP4/5D36idd7EVGpuOVt+YovNd95U+/z0++xsvM/3x78f8f+P6+bzgedS4DU8/9b83v913X0GeF4679K3gep8Pxg/P2jxHb/+GuidKGhFWsV6B2rvQME/H7h3gP5sy+ZWy/ctjP28rq+d1OfP6CmUZ+tfg/z+PxaitxIXg/c7uGB5DuFdQNBfMKHzJtznyo16dN3EcwrtXQkB+VucPj/cZ46WGv9604+sfN65v183v7MV/XtL+BXk/Hn963Xj0t+zckP/beZY33f+5/W07X5W9Cv6+jtn1XP3zC56zIQ6v5v62sp9x32DKTR1NSwt28JfYohyH41HBdWTrC077eAxXXOedB0X3XLdHbfv63STJUa/jS+88X76cC/WUHzzk6y5EPVwx5fQwgqVJM+b9hj8Zy3uTtvsNHe2yszLcat3DOb4yj9+mH/6hXNUCs7Z+okV6/JewWYZypyeuY2MuPMGNd0Afz1+/yivgQwmRVkl0gjseIYYyf0PE4Sb6MCNidenXFxZ7wCEiKkTi3GBDJA1F5LLzhbvi3MEspKgztJ9iH6QAZeSXyzSxxAyuaGSmJqvFHdv9clz2XAdMiMTKeRQyE0LnWTFmMBPiRUM9RRSTCnlVFJNLfUccswp51yySLGXUKIpqeRSSi2t9B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cG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICA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;
abAlertBoxTickAction = null;
abAlertBoxCrossAction = null;
let titleContent = "<span style=\"font-size:14px;padding:2px;\">";
// titleContent += '<i class="fa '+abAlertBoxStack[0].headericon+'"> </i> ';
titleContent += `<img src="${tbIcon}">`;
titleContent += abAlertBoxStack[0].title;
titleContent += "</span>";
$("#abAlerts #header").html(titleContent);
$("#abAlerts #content").html(abAlertBoxStack[0].content);
document.getElementById("abAlertTickBtnCaption").innerHTML = modifyHTML(
abAlertBoxStack[0].tickText,
);
if (abAlertBoxStack[0].hasCross) {
document.getElementById("abAlertCrossBtnCaption").innerHTML = modifyHTML(
abAlertBoxStack[0].crossText,
);
$("#abAlertCrossBtn").show();
if (typeof abAlertBoxStack[0].crossAction === "function") {
abAlertBoxCrossAction = abAlertBoxStack[0].crossAction;
}
} else {
$("#abAlertCrossBtn").hide();
}
if (typeof abAlertBoxStack[0].tickAction === "function") {
abAlertBoxTickAction = abAlertBoxStack[0].tickAction;
}
$("#abAlerts").fadeIn(200);
abAlertBoxStack.shift();
}
function abInitialiseAlertBox() {
// create a new div to display script alerts
abAlerts = document.createElement("div");
abAlerts.id = "abAlerts";
const alertsHTML = `
<div id="header">Alert title goes here...</div>
<div id="content">Alert content goes here...</div>
<div id="controls" align="center">
<span id="abAlertTickBtn">
<i class="fa fa-check"> </i>
<span id="abAlertTickBtnCaption" style="font-weight: bold;"></span>
</span>
<span id="abAlertCrossBtn">
<i class="fa fa-times"> </i>
<span id="abAlertCrossBtnCaption" style="font-weight: bold;"></span>
</span>
</div>
`;
abAlerts.innerHTML = modifyHTML(alertsHTML);
abAlerts.style.display = "none";
document.body.appendChild(abAlerts);
}
function SetStyle(elm, style, value, important) {
if (elm !== null && elm != undefined) {
if (important === true) {
value += "!important";
}
elm.style[style] = value;
}
}
function modifyHTML(htmlIn) {
if (typeof trustedTypes === "undefined") {
return htmlIn;
}
const escapeHTMLPolicy = trustedTypes.createPolicy("forceInner", {
createHTML: to_escape => to_escape,
});
return escapeHTMLPolicy.createHTML(htmlIn);
}
function reorderDaysOfWeek(origDOWs) {
const dows = [];
for (let i = 0; i < 6; ++i) {
dows.push(origDOWs[i + 1]);
}
dows.push(origDOWs[0]);
return dows;
}
// contrast items
function GetBorderContrast(contrast, isImportant) {
let retval = `border: 1px solid ${["", "lightgrey", "grey"][contrast]}`;
if (isImportant === true) {
retval += "!important";
}
retval += "; ";
return retval;
}
// Mutation Observer for daterangepicker in Restrictions
const RestrictionObserver = new MutationObserver(mutations => {
if (options.mondayFirst || options.ISODates) {
mutations.forEach(mutation => {
if ($(mutation.target).hasClass("modal-content")) {
if (mutation.addedNodes.length > 0) {
if ($(".datepicker").length > 0) {
const DRP = $(".datepicker")[0];
const dows = reorderDaysOfWeek(
$(DRP).data("daterangepicker").locale.daysOfWeek,
);
if (options.mondayFirst) {
if ($(DRP).data("daterangepicker").locale.firstDay === 0) {
$(DRP).data("daterangepicker").locale.firstDay = 1;
$(DRP).data("daterangepicker").locale.daysOfWeek = dows;
}
}
if (options.ISODates) {
$(DRP).data("daterangepicker").locale.format = "YYYY-MM-DD";
DRP.value = `${$(DRP).data("daterangepicker").startDate._i} - ${
$(DRP).data("daterangepicker").endDate._i
}`;
}
}
}
}
});
}
});
// Mutation Observer for segment edit panel
const SegmentObserver = new MutationObserver(mutations => {
// Tame the locked segment message which, in some locales, takes up rather more space than would be ideal
if (options.tameLockedSegment) {
const tObj = document.getElementsByClassName("segment-details");
if (tObj.length > 0) {
if (
tObj[0].firstChild.textContent
== I18n.lookup("edit.segment.permissions.locked.title")
) {
tObj[0].firstChild.textContent = "Segment locked";
tObj[0].childNodes[1].firstChild.firstChild.textContent = "";
} else if (
tObj[0].firstChild.textContent
== I18n.lookup("edit.segment.permissions.locked_except_closures.title")
) {
tObj[0].firstChild.textContent = "Segment locked except for closures";
tObj[0].childNodes[1].firstChild.firstChild.textContent = "";
}
}
}
// Hide the labels in the segment edit panel to give more vertical space to the things we need to interact with
if (options.hideSegmentPanelLabels) {
let tObj = document
.getElementById("edit-panel")
.getElementsByTagName("wz-tab");
if (tObj.length > 0) {
tObj = tObj[0].getElementsByTagName("wz-label");
if (tObj.length > 0) {
for (const l of tObj) {
if (l.getElementsByTagName("wz-checkbox").length == 0) {
l.style.display = "none";
}
}
}
}
}
// Remove those options from the elevation menu which no-one is ever likely to need
if (options.tameElevationMenu) {
if (document.getElementsByName("level").length > 0) {
if (document.getElementsByName("level")[0].childElementCount > 0) {
const menuEntries = document
.getElementsByName("level")[0]
.getElementsByTagName("wz-option");
const localeGround = I18n.lookup("edit.segment.levels")[0];
for (const pe of menuEntries) {
let level = 0;
if (pe.value != localeGround) {
level = parseInt(pe.value);
}
if (level > 5 || level < -5) {
SetStyle(pe, "display", "none", false);
} else {
const sr = pe.shadowRoot.querySelector(".wz-menu-item");
const indent = 44 + level * 8;
SetStyle(sr, "padding", `0px 0px 0px ${indent}px`, false);
SetStyle(sr, "height", "100%", false);
SetStyle(sr, "lineHeight", "100%", false);
SetStyle(sr, "minHeight", "auto", false);
}
}
}
}
}
// Remove whitespace from the segment type menu if it's being used
if (options.tameSegmentTypeMenu) {
// Check the menu is being shown - this won't be the case in compact mode
if (document.getElementsByName("roadType").length > 0) {
if (document.getElementsByName("roadType")[0].childElementCount > 0) {
const menuDividers = document
.getElementsByName("roadType")[0]
.getElementsByTagName("wz-menu-divider");
let pe;
let sr;
for (pe of menuDividers) {
SetStyle(pe, "display", "none", false);
}
const menuTitles = document
.getElementsByName("roadType")[0]
.getElementsByTagName("wz-menu-title");
for (pe of menuTitles) {
sr = pe.shadowRoot.querySelector(".wz-menu-title");
SetStyle(sr, "padding", "0px, 0px, 0px 4px", false);
SetStyle(sr, "height", "100%", false);
SetStyle(sr, "lineHeight", "100%", false);
SetStyle(sr, "minHeight", "auto", false);
}
const menuEntries = document
.getElementsByName("roadType")[0]
.getElementsByTagName("wz-option");
for (pe of menuEntries) {
sr = pe.shadowRoot.querySelector(".wz-menu-item");
SetStyle(sr, "padding", "0px 0px 0px 24px", false);
SetStyle(sr, "height", "100%", false);
SetStyle(sr, "lineHeight", "100%", false);
SetStyle(sr, "minHeight", "auto", false);
}
}
}
}
// Remove that slightly annoying "used as" message under the routing option buttons
if (options.removeRoutingReminder) {
SetStyle(
document.querySelector(".routing-road-type-message")?.parentElement,
"display",
"none",
false,
);
}
if (options.restyleSidePanel) {
if (options.UICompression > 0) {
// Reduce padding enough so that the compact mode segment type selectors stand a reasonable chance
// of fitting onto two lines instead of needing to spill over onto a third...
SetStyle(
document.querySelector("wz-tab")?.shadowRoot.querySelector(".wz-tab"),
"padding",
"2px",
false,
);
// Reduce gap between the "Select entire street" and "Edit house numbers" buttons
SetStyle(
document.querySelector("#edit-panel .more-actions"),
"gap",
"0px",
false,
);
// Reduce gap under the direction and lock level selectors
SetStyle(
document.querySelector("segment-direction-editor"),
"marginBottom",
"0px",
false,
);
SetStyle(
document.querySelector(".lock-edit-view"),
"marginBottom",
"0px",
false,
);
// Reduce height of the speed limit input boxes
const nSLE = document.querySelectorAll(
"#segment-edit-general .speed-limit-input",
).length;
if (nSLE > 0) {
for (let i = 0; i < nSLE; ++i) {
const sr = document.querySelectorAll(
"#segment-edit-general .speed-limit-input",
)[i].shadowRoot;
SetStyle(
sr.querySelector(".wz-text-input"),
"height",
"26px",
false,
);
}
}
// Reduce height of the elevation drop-down - all this just to tweak the height of ONE UI element, thank you
// VERY much shadowroot :-/
if (document.getElementsByName("level")[0] != undefined) {
const sr = document.getElementsByName("level")[0].shadowRoot;
SetStyle(sr.querySelector(".wz-select"), "height", "20px", false);
SetStyle(
sr.querySelector(".selected-value-wrapper"),
"height",
"20px",
false,
);
SetStyle(sr.querySelector(".select-wrapper"), "height", "20px", false);
SetStyle(sr.querySelector(".select-box"), "height", "20px", false);
}
}
}
});
// Mutation Observer for daterangepicker in Closures
const ClosureObserver = new MutationObserver(mutations => {
if (options.mondayFirst) {
mutations.forEach(mutation => {
if (mutation.target.className == "closures") {
if (mutation.addedNodes.length > 0) {
if (
mutation.addedNodes[0].firstChild.classList.contains(
"edit-closure",
)
) {
if (
$(".start-date").data("daterangepicker").locale.firstDay === 0
) {
$(".start-date").data("daterangepicker").locale.firstDay = 1;
$(".end-date").data("daterangepicker").locale.firstDay = 1;
const dows = reorderDaysOfWeek(
$(".start-date").data("daterangepicker").locale.daysOfWeek,
);
$(".start-date").data("daterangepicker").locale.daysOfWeek = dows;
$(".end-date").data("daterangepicker").locale.daysOfWeek = dows;
}
}
}
}
});
}
});
// Mutation Observer for place edit panel
const PlaceObserver = new MutationObserver(mutations => {
// This slightly convoluted bit of code allows us to manipulate
// the entries in the dynamically created drop-down list which
// is generated whenever you start searching for a GMaps place
// to link to a native one
if (options.fixExternalProviders) {
// First check that the MO has fired because the user has selected
// a place for editing...
const acMenu = document.getElementsByClassName(
"external-provider-edit-form",
)[0];
if (acMenu !== undefined) {
// ...and then check the "add linked Google place" option has been
// selected, to start the process of generating the dynamic list
const acInner = acMenu.getElementsByTagName("wz-autocomplete")[0];
if (acInner !== undefined) {
// If so, then we now need to poll the UI to see if there are any
// list items present - this doesn't appear to be possible via a
// MO due to the items being hidden behind shadowroot, hence the
// slightly old-school nature of polling vs event driven here :-/
window.setTimeout(EPObserver, 500);
}
}
}
if (options.UICompression > 0) {
// Also check for the existence of the entry point UI element, so
// we can dive into its shadowroot to deal with its excessive whitespace
if (
document.getElementsByClassName(
"navigation-point-item navigation-point-editable",
).length > 0
) {
const npOuter = document.getElementsByClassName(
"navigation-point-item navigation-point-editable",
)[0];
const npInner = npOuter.shadowRoot.querySelectorAll(".list-item-wrapper");
if (npInner.length > 0) {
for (const i of npInner) {
i.style.paddingTop = "4px";
i.style.paddingBottom = "4px";
}
}
}
}
});
// Mutation Observer for issue tracker panel
const ITObserver = new MutationObserver(mutations => {
disableUITransitions();
});
const MTEObserver = new MutationObserver(mutations => {
checkForMTEDropDown();
});
// To unwind the temporary moving of the notification icons when entering HN edit mode above, we observe changes in the primary
// toolbar in order to detect when the close HN editor button is displayed, and also when the regular toolbar contents are
// displayed. We use the former to set up an onclick handler so that when the close editor button is clicked, we set a flag
// to then trigger the deferred unwinding of the icon move once we detect the toolbar is back to normal...
let doCleanUpAfterHNEdit = false;
const PriToolBarObserver = new MutationObserver(mutation => {
if (document.querySelector("wz-button.waze-icon-exit") !== null) {
// The HN topbar buttons don't exist within the DOM until the user initiates HN editing, so we need to
// perform a seperate application of the button-specific parts of the topbar compression mods
CheckForHNButtons();
}
if (
document.querySelector(
"#primary-toolbar .toolbar-collection-component",
) !== null
) {
if (
document.querySelector(".toolbar-group").getBoundingClientRect()
.width !== 0
) {
if (doCleanUpAfterHNEdit) {
doCleanUpAfterHNEdit = false;
hideMenuLabels();
if (options.moveUserInfo) {
insertNodeBeforeNode(
document.querySelector(".user-toolbar"),
getById("left-app-head"),
);
insertNodeBeforeNode(
document.querySelector("wz-user-box"),
getById("left-app-head"),
);
}
}
}
}
});
function CheckForHNButtons() {
// The shadowroots for the HN topbar buttons get filled in slightly after the topbar mutation observer fires, which means
// we can't do a simple (because when has dealing with the WME UI design EVER been simple...) call to the code that applies
// the appropriate compression settings to those buttons. Instead we call the function, which will return false so long as
// it saw any empty shadowroot containers - i.e. for any buttons which WME hasn't finished rendering. We use this return
// value to then trigger a short duration timeout before trying to apply the compression again, and so on until it works...
if (ApplyTopBarShadowRootWzButtonCompression() === false) {
window.setTimeout(CheckForHNButtons, 10);
}
}
function PrepForHNEdit() {
// Moving the notification icons prevents the HN buttons from being rendered, so if the user has opted to move them, temporarily
// move them back if the user then goes to edit HN...
if (options.moveUserInfo) {
insertNodeAfterNode(
document.querySelector("wz-user-box"),
document.querySelector("#save-button").parentElement.parentElement,
);
insertNodeAfterNode(
document.querySelector(".user-toolbar"),
document.querySelector("#save-button").parentElement.parentElement,
);
doCleanUpAfterHNEdit = true;
}
}
function checkForMTEDropDown() {
const tObj = document.querySelector("#sidepanel-mtes");
let nWO = tObj?.querySelectorAll("wz-option").length;
let nSR = 0;
while (nWO) {
if (tObj.querySelectorAll("wz-option")[nWO - 1].shadowRoot != null) {
++nSR;
}
--nWO;
}
if (nSR > 0) {
restyleDropDownEntries();
} else {
window.setTimeout(checkForMTEDropDown, 100);
}
}
function EPObserver() {
// Just a quick sanity check to make sure the list elements we need are
// all still present...
const acMenu = document.getElementsByClassName(
"external-provider-edit-form",
)[0];
if (acMenu == undefined) return;
const acInner = acMenu.getElementsByTagName("wz-autocomplete")[0];
if (acInner == undefined) return;
// Now that we're back to the same position we were at when we originally
// started polling, it's time to mess with whichever list items we can
// find here
const acEntries = acInner.shadowRoot.querySelectorAll("wz-menu-item");
if (acEntries.length != 0) {
for (const i of acEntries) {
// To accommodate suggestions that wrap onto 3+ lines, we need to remove the
// height styling from the main menu item plus its child elements, so that each
// entry can expand as needed to keep all of the text visible
SetStyle(i, "--wz-menu-option-height", "auto", false);
const wai = i.querySelector(".wz-autocomplete-item");
SetStyle(wai, "height", "auto", false);
SetStyle(wai, "padding-top", "2px", false);
SetStyle(wai, "padding-bottom", "2px", false);
// Most of the restyling fun takes place on this child element within the
// list element
const acText = i.querySelector(".wz-string-wrapper.primary-text");
// Restore some sanity to the entries, so we can see exactly what they
// say and therefore know what it is we're selecting - UI Design 101...
SetStyle(acText, "overflow", "visible", false);
SetStyle(acText, "overflow", "visible", false);
SetStyle(acText, "lineHeight", "100%", false);
SetStyle(acText, "display", "block", false);
SetStyle(acText, "whiteSpace", "normal", false);
// And just for shits and giggles, the late April WME update now places each and every
// character within an entry in its own childnode of that entry, so that styling can be
// applied to each character individually... As this messes up the entry lineheight
// styling which used to be all that was needed to get things looking good here, we now
// ALSO need to override the native styling on these child nodes. What next devs, an
// individual node for each pixel of each character???
const acChars = acText.childNodes;
for (const j of acChars) {
SetStyle(j, "lineHeight", "100%", false);
}
// We also need to tweak the shadowroot version of the menu item itself, to
// adjust the height style to prevent the item failing to grow tall enough
// to fully accommodate 3+ line entries
const srMenuItems = i.shadowRoot.querySelector(".wz-menu-item");
SetStyle(srMenuItems, "height", "auto", false);
}
}
// Having messed with whichever elements we found this time around, poll again
// to account for the user continuing to type in the search box causing the
// list to be regenerated with differing entries. As we only get this far into
// the function if the list is still visible, as soon as the user finishes their
// search and the list is removed, the polling will stop until the next time
// the MO fires - part-time polling, I can live with that if the alternative is
// leaving the list entries in a sometimes unuseable state due to the odd
// choice of native styles...
window.setTimeout(EPObserver, 100);
}
// Don't try to manipulate I18n if we're currently running within the scope of the login popup, because I18n doesn't
// exist there, and we need to get past here without throwing an exception in order to be able to modify the CSS
// within the popup...
if (document.location.href.indexOf("signin") == -1) {
// Fix for date/time formats in WME released Oct/Nov 2016 - provided by Glodenox
I18n.translations[I18n.currentLocale()].time = {};
I18n.translations[I18n.currentLocale()].time.formats = {};
I18n.translations[I18n.currentLocale()].time.formats.long = "%a %b %d %Y, %H:%M";
I18n.translations[I18n.currentLocale()].date.formats = {};
I18n.translations[I18n.currentLocale()].date.formats.long = "%a %b %d %Y, %H:%M";
I18n.translations[I18n.currentLocale()].date.formats.default = "%a %b %d %Y";
}
function newSaveMode() {
const sm = W.editingMediator.attributes.saveMode;
if (sm === "IDLE") {
float();
}
}
function init1() {
logit("Starting init1", "debug");
// Hide the "accept cookies" panel in the login popup
if (document.location.href.indexOf("signin") != -1) {
addGlobalStyle(".wz-cc-container { display: none; }");
}
if (W === undefined) {
window.setTimeout(init1, 100);
return;
}
logit("Initialising...");
if (W.userscripts?.state?.isReady) {
init1Finalise();
} else {
document.addEventListener("wme-ready", init1Finalise, {
once: true,
});
}
}
function init1Finalise() {
// insert the content as a tab
addMyTab();
}
function init2() {
logit("Starting init2", "debug");
if (W.userscripts === undefined) {
// go round again if my tab isn't there yet
if (!getById("sidepanel-FixUI")) {
logit("Waiting for my tab to appear...", "warning");
setTimeout(init2, 200);
return;
}
}
// setup event handlers for controls:
getById("street-view-drag-handle").ondblclick = GSVWidthReset;
// REGISTER WAZE EVENT HOOKS
// events for Aerial Shifter
W.map.events.register("zoomend", null, shiftAerials);
W.map.events.register("moveend", null, shiftAerials);
W.map
.getLayerByUniqueName("satellite_imagery")
.events.register("loadend", null, shiftAerials);
// events to change menu bar color based on map comments checkbox
W.map.events.register("zoomend", null, warnCommentsOff);
W.map.events.register("moveend", null, warnCommentsOff);
// event to remove the overlay that blocks the sidebar UI if you zoom out too far
W.map.events.register("zoomend", null, unblockSidePanel);
// events to adjust the "Search this area" z-index so it gets rendered behind the drop-down menus
W.map.events.register("zoomend", null, moveSearchThisArea);
W.map.events.register("moveend", null, moveSearchThisArea);
// event to re-hack my zoom bar if it's there
W.map
.getLayerByUniqueName("BASE_LAYER")
.events.register("loadend", null, ZLI);
// window resize event to resize chat
window.addEventListener("resize", enhanceChat, true);
// window resize event to resize layers menu
window.addEventListener("resize", compressLayersMenu, true);
// window resize event to reapply zoombar fix
window.addEventListener("resize", ZLI, true);
// window resize event to resize search box
window.addEventListener("resize", resizeSearch, true);
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", e => {
updateTheme();
});
// anything we might need to do when the mouse moves...
W.map.events.register("mousemove", null, mouseMove);
const tEvt = {
...W.editingMediator._events["change:saveMode"][0],
};
tEvt.callback = newSaveMode;
W.editingMediator._events["change:saveMode"].push(tEvt);
// event handlers to help with the weird change log visibility problem...
document
.querySelector("#save-button")
.addEventListener("mouseover", saveMouseOver, true);
document
.querySelector("#save-button")
.addEventListener("mouseout", saveMouseOut, true);
// window resize event to refloat the sharing box in the correct location
window.addEventListener("resize", unfloat, true);
// event to re-hack toolbar buttons on exiting HN mode
W.editingMediator.on("change:editingHouseNumbers", () => {
if (W.editingMediator.attributes.editingHouseNumbers === true) {
PrepForHNEdit();
}
if (options.unfloatButtons) {
if (W.editingMediator.attributes.editingHouseNumbers) unfloat();
if (W.editingMediator.attributes.editingEnabled) unfloat();
}
});
// create Aerial Shifter warning div
const ASwarning = document.createElement("div");
ASwarning.id = "WMEFU_AS";
ASwarning.innerHTML = modifyHTML("Aerials Shifted");
ASwarning.setAttribute(
"style",
"top:20px; left:0px; width:100%; position:absolute; z-index:10000; font-size:100px; font-weight:900; color:rgba(255, 255, 0, 0.4); text-align:center; pointer-events:none; display:none;",
);
getById("WazeMap").appendChild(ASwarning);
// Add an extra checkbox so I can test segment panel changes easily
if (W.loginManager.user.attributes.userName == "Twister-UK") {
logit("creating segment detail debug checkbox", "info");
const extraCBSection = document.createElement("p");
extraCBSection.innerHTML = modifyHTML(
"<input type=\"checkbox\" id=\"_cbextraCBSection\" />",
);
insertNodeBeforeNode(extraCBSection, getById("left-app-head"));
getById("_cbextraCBSection").onclick = FALSEcompressSegmentTab;
getById("_cbextraCBSection").checked = getById(
"_cbCompressSegmentTab",
).checked;
}
// create Panel Swap div
const WMEPS_div = document.createElement("div");
const WMEPS_div_sub = document.createElement("div");
WMEPS_div.id = "WMEFUPS";
WMEPS_div.setAttribute(
"style",
"color: lightgrey; margin-left: 5px; font-size: 20px;",
);
WMEPS_div.title = "Panel Swap: when map elements are selected, this lets you\nswap between the edit panel and the other tabs.";
WMEPS_div_sub.innerHTML = modifyHTML("<i class=\"fa fa-sticky-note\"></i>");
WMEPS_div.appendChild(WMEPS_div_sub);
insertNodeBeforeNode(WMEPS_div, getById("left-app-head"));
getById("WMEFUPS").onclick = PSclicked;
W.selectionManager.events.register("selectionchanged", null, PSicon);
// create Permalink Count div
const WMEPC_div = document.createElement("div");
const WMEPC_div_sub = document.createElement("div");
WMEPC_div.id = "WMEFUPC";
WMEPC_div.classList.add("toolbar-button", "toolbar-button-with-icon");
WMEPC_div.title = "Number of selectable map objects in the URL\nClick to reselect them.";
WMEPC_div_sub.classList.add("item-container", "WMEFU-toolbar-button");
let totalItems;
if (location.search.match("segments")) {
totalItems = window.location.search
.match(new RegExp("[?&]segments?=([^&]*)"))[1]
.split(",").length;
} else if (location.search.match("venues")) {
totalItems = window.location.search
.match(new RegExp("[?&]venues?=([^&]*)"))[1]
.split(",").length;
} else if (location.search.match("nodes")) {
totalItems = Math.min(
1,
window.location.search
.match(new RegExp("[?&]nodes?=([^&]*)"))[1]
.split(",").length,
);
} else if (location.search.match("mapComments")) {
totalItems = Math.min(
1,
window.location.search
.match(new RegExp("[?&]mapComments?=([^&]*)"))[1]
.split(",").length,
);
} else if (location.search.match("cameras")) {
totalItems = Math.min(
1,
window.location.search
.match(new RegExp("[?&]cameras?=([^&]*)"))[1]
.split(",").length,
);
} else totalItems = 0;
WMEPC_div_sub.innerHTML = modifyHTML(
`<span class="item-icon" style="display:inline-flex"><i style="margin-top:8px" class="fa fa-link WMEFUPCicon"></i> ${
totalItems
}</span>`,
);
WMEPC_div.appendChild(WMEPC_div_sub);
insertNodeBeforeNode(WMEPC_div, getById("search"));
WMEPC_div.onclick = PCclicked;
// Create Turn Popup Blocker div
const WMETPB_div = document.createElement("div");
const WMETPB_div_sub = document.createElement("div");
WMETPB_div.id = "WMEFUTPB";
WMETPB_div.classList.add("toolbar-button", "toolbar-button-with-icon");
WMETPB_div.title = "Disable/enable the turn arrow popup dialogue";
WMETPB_div_sub.classList.add("item-container", "WMEFU-toolbar-button");
WMETPB_div_sub.innerHTML = modifyHTML(
"<span class=\"item-icon fa-stack fa-2x\" style=\"display:inline-flex; font-size:10px !important\"><i class=\"fa fa-comment fa-stack-2x\"></i><i class=\"fa fa-arrow-up fa-inverse fa-stack-1x\"></i></span>",
);
WMETPB_div.appendChild(WMETPB_div_sub);
insertNodeBeforeNode(WMETPB_div, getById("search"));
WMETPB_div.onclick = toggleKillTurnPopup;
addGlobalStyle(".WMEFU-toolbar-button { padding: 0px !important; }");
// overload the window unload function to save my settings
window.addEventListener("beforeunload", saveSettings, false);
// Alert to new version
if (options.oldVersion != FUME_VERSION) {
const releaseNotes = `
<div>
<div>Version ${FUME_VERSION} (${FUME_DATE}) release notes</div>
<ul>
${
newVersionNotes.length > 0
? newVersionNotes.map(note => `<li>${note}`).join("")
: "<li>No changes"
}
</ul>
</div>
`;
abShowAlertBox(
"fa-info-circle",
"WME Fix UI Memorial Edition",
releaseNotes,
false,
"OK",
"",
null,
null,
);
saveSettings();
}
// fix for sidebar display problem in Safari, requested by edsonajj
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (isSafari) {
addGlobalStyle(".flex-parent { height: 99% !important; }");
}
// stop wobbling status bar
addGlobalStyle(".WazeControlMousePosition { font-family: monospace }");
// move closed node icon below node markers
// apply the settings
shiftAerials();
window.setTimeout(applyAllSettings, 1000);
logit("Initialisation complete");
}
let wasDrawing = null;
function mouseMove() {
// Temporarily disable the Enlarge geo/junction nodes and Enlarge geo handles options
// when drawing new geometry, to avoid the enlarged nodes/handles on other geometry