-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathWME-BED.user.js
2664 lines (2472 loc) · 142 KB
/
WME-BED.user.js
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 BackEnd Data
// @namespace https://github.com/thecre8r/
// @version 2024.07.07.01
// @description Shows Hidden Attributes, AdPins, and Gas Prices for Applicable Places
// @match https://www.waze.com/editor*
// @match https://www.waze.com/*/editor*
// @match https://beta.waze.com/editor*
// @match https://beta.waze.com/*/editor*
// @match https://support.google.com/waze/answer/7402261*
// @exclude https://www.waze.com/user/editor*
// @icon data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><g><path fill="rgb(120, 176, 191)" d="M176 256c44.11 0 80-35.89 80-80s-35.89-80-80-80-80 35.89-80 80 35.89 80 80 80zm352-128H304c-8.84 0-16 7.16-16 16v144H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v352c0 8.84 7.16 16 16 16h32c8.84 0 16-7.16 16-16v-48h512v48c0 8.84 7.16 16 16 16h32c8.84 0 16-7.16 16-16V240c0-61.86-50.14-112-112-112z" class=""></path></g></svg>
// @author The_Cre8r
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @require https://unpkg.com/[email protected]/lib/qr-code-styling.js
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @require https://www.cssscript.com/demo/minimal-json-data-formatter-jsonviewer/json-viewer.js
// @license GPLv3
// @connect gapi.waze.com
// @grant GM_xmlhttpRequest
// ==/UserScript==
/* global W */
/* global OpenLayers */
/* ecmaVersion 2017 */
/* global $ */
/* global I18n */
/* global _ */
/* global WazeWrap */
/* global WMECS */
/* global require */
/* global QRCodeStyling */
/* global Backbone */
/* global JSONViewer */
(function() {
'use strict';
const STORE_NAME = "WMEBED_Settings";
const SCRIPT_NAME = GM_info.script.name;
const SCRIPT_VERSION = GM_info.script.version.toString();
//{"version": "2024.07.07.01","changes": "Insert Changes Here"},
const SCRIPT_HISTORY = `{"versions": [{"version": "2024.07.07.01","changes": "Closed <a href='https://github.com/TheCre8r/WME-BackEnd-Data/issues/39' target='_blank'>GitHub Issue 39</a>"},{"version": "2024.06.30.01","changes": "<li>Disabled Ad Functionality <a href='https://support.google.com/wazeads/answer/14260169?sjid=8425293986048490789-NA' target='_blank'>More Info Here</a></li><li>Added Parking Provider Information</li><li>Minor bug fixes</li><li>Code cleanup</li>"},{"version": "2024.04.28.01","changes": "Update to get gas tab and feed links to show again."}]}`;
const GH = {link: 'https://github.com/TheCre8r/WME-BackEnd-Data/', issue: 'https://github.com/TheCre8r/WME-BackEnd-Data/issues/new', wiki: 'https://github.com/TheCre8r/WME-BackEnd-Data/wiki'};
const UPDATE_ALERT = true;
const USER = {name: null, rank:null};
const SERVER = {name: null};
const COUNTRY = {id: 0, name: null};
const icons = {bed: "fa fa-bed", github: "fa fa-github", "help": "w-icon w-icon-query-fill", qrcode: "fa fa-qrcode", download: "fa fa-download", wme:"w-icon w-icon-map-edit", livemap:"fa fa-map-o", "search-server": "fa fa-server"}
const adsFeatures = false;
let _ads = [];
let _settings = {};
let _adPinsLayer;
//let _PsudoVenueLayer;
let streetAlias = { // Used when matching ad addresses for newly created places. Format: Waze Abbreviation:Ad Street Name
'1ST':'FIRST','2ND':'SECOND','3RD':'THIRD','4TH':'FOURTH','5TH':'FIFTH','6TH':'SIXTH','7TH':'SEVENTH','8TH':'EIGHTH','9TH':'NINTH','10TH':'TENTH',
'FIRST':'1ST','SECOND':'2ND','THIRD':'3RD','FOURTH':'4TH','FIFTH':'5TH','SIXTH':'6TH','SEVENTH':'7TH','EIGHTH':'8TH','NINTH':'9TH','TENTH':'10TH',
'NORTH':'N','SOUTH':'S','EAST':'E','WEST':'W','N':'NORTH','S':'SOUTH','E':'EAST','W':'WEST',
'AVE':'AVENUE','PKY':['PARKWAY','PKWY'],'PKWY':['PARKWAY','PKY'],'ST':'STREET','RD':'ROAD','DR':'DRIVE','PLZ':'PLAZA','CIR':'CIRCLE',
'I-':'IH-','NE':'NORTHEAST','NW':'NORTHWEST','SE':'SOUTHEAST','SW':'SOUTHWEST'
};
function log(msg,level) {
if (level >= 0 && _settings.Debug !== true) {
return;
}
var css = 'font-size: 12px; display: block; ';
switch (level) {
case 0:
css += 'color: green;'
break;
case 1:
css += 'color: orange;'
break;
case 2:
css += 'color: red;'
break;
default:
css += 'color: white;'
break;
}
console.log("%c"+GM_info.script.name+": %s", css, msg);
if (typeof msg === 'object' && _settings.Debug == true) {
console.log(msg)
}
}
/*-- START Google Form Filler --*/
function fillForm() {
if (getUrlParameter('username') != "") {
injectCssGoogle();
document.getElementsByName('username')[0].value = getUrlParameter('username');
document.getElementsByName('brand_name')[0].value = getUrlParameter('brand_name');
document.getElementsByName('incorrect_gps_coordinates')[0].value = getUrlParameter('incorrect_gps_coordinates');
document.getElementsByName('pin_address')[0].value = getUrlParameter('pin_address');
document.getElementsByName('correct_gps_coordinates')[0].value = getUrlParameter('correct_gps_coordinates');
document.getElementsByName('description')[1].value = getUrlParameter('description');
if (getUrlParameter('p1') == 'true') {
document.querySelector('#misplaced_ad_pins > div:nth-child(10) > fieldset > div:nth-child(3) > div > label').click()
}
else if (getUrlParameter('p2') == 'true') {
document.querySelector('#misplaced_ad_pins > div:nth-child(10) > fieldset > div:nth-child(3) > div > label').click()
}
$("#misplaced_ad_pins > div:nth-child(17) > fieldset > div:nth-child(3) > div > label > div.material-radio__circle").click()
let addressLabel;
let addressID = document.getElementsByName('pin_address')[0].id;
for (let i=0;i<document.getElementsByTagName('label').length;i++) {
if (document.getElementsByTagName('label')[i].getAttribute('for') == addressID) {
addressLabel = document.getElementsByTagName('label')[i];
}
}
let addressNote = document.createElement('div');
addressNote.setAttribute('style','color:red;font-weight:bold;');
addressNote.innerText = "Autofilled address may differ from address displayed on the ad in the Waze app.";
addressLabel.append(addressNote);
let qrContainer = document.createElement('div');
qrContainer.className = 'sibling-nav';
qrContainer.setAttribute('style','padding-left:42px;');
let qrTitle = document.createElement('h4');
qrTitle.innerText = 'Open in the Waze App';
let qrCode = document.createElement('div');
qrCode.id = 'appLinkQRCode';
qrCode.setAttribute('style','padding-left:42px;');
qrContainer.append(qrTitle);
qrContainer.append(qrCode);
document.getElementsByClassName('fixed-sidebar-container')[0].append(qrContainer);
displayQrCode("appLinkQRCode", getUrlParameter('adid'));
}
}
/*-- End Google Form Filler --*/
/*-- START Libraries --*/
function installOpenLayersIcon() {
log('Installing OpenLayers.Icon');
OpenLayers.Icon = OpenLayers.Class({
url: null,
size: null,
offset: null,
calculateOffset: null,
imageDiv: null,
px: null,
initialize: function(a,b,c,d){
this.url=a;
this.size=b||{w: 20,h: 20};
this.offset=c||{x: -(this.size.w/2),y: -(this.size.h/2)};
this.calculateOffset=d;
a=OpenLayers.Util.createUniqueID("OL_Icon_");
let div = this.imageDiv=OpenLayers.Util.createAlphaImageDiv(a);
$(div.firstChild).removeClass('olAlphaImg'); // LEAVE THIS LINE TO PREVENT WME-HARDHATS SCRIPT FROM TURNING ALL ICONS INTO HARDHAT WAZERS --MAPOMATIC
},
destroy: function(){ this.erase();OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);this.imageDiv.innerHTML="";this.imageDiv=null; },
clone: function(){ return new OpenLayers.Icon(this.url,this.size,this.offset,this.calculateOffset); },
setSize: function(a){ null!==a&&(this.size=a); this.draw(); },
setUrl: function(a){ null!==a&&(this.url=a); this.draw(); },
draw: function(a){
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,null,this.size,this.url,"absolute");
this.moveTo(a);
return this.imageDiv;
},
erase: function(){ null!==this.imageDiv&&null!==this.imageDiv.parentNode&&OpenLayers.Element.remove(this.imageDiv); },
setOpacity: function(a){ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,null,null,null,null,null,null,a); },
moveTo: function(a){
null!==a&&(this.px=a);
null!==this.imageDiv&&(null===this.px?this.display(!1): (
this.calculateOffset&&(this.offset=this.calculateOffset(this.size)),
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,null,{x: this.px.x+this.offset.x,y: this.px.y+this.offset.y})
));
},
display: function(a){ this.imageDiv.style.display=a?"": "none"; },
isDrawn: function(){ return this.imageDiv&&this.imageDiv.parentNode&&11!=this.imageDiv.parentNode.nodeType; },
CLASS_NAME: "OpenLayers.Icon"
});
}
/*
Copyright (c) 2011 Andrei Mackenzie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Compute the edit distance between the two given strings
function getEditDistance(a, b){
if(a.length == 0) return b.length;
if(b.length == 0) return a.length;
var matrix = [];
// increment along the first column of each row
var i;
for(i = 0; i <= b.length; i++){
matrix[i] = [i];
}
// increment each column in the first row
var j;
for(j = 0; j <= a.length; j++){
matrix[0][j] = j;
}
// Fill in the rest of the matrix
for(i = 1; i <= b.length; i++){
for(j = 1; j <= a.length; j++){
if(b.charAt(i-1) == a.charAt(j-1)){
matrix[i][j] = matrix[i-1][j-1];
} else {
matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution
Math.min(matrix[i][j-1] + 1, // insertion
matrix[i-1][j] + 1)); // deletion
}
}
}
return matrix[b.length][a.length];
};
function restoreTabPane() {
if (document.querySelector("#WMEBED-ad-pin-sidebar")) {
document.querySelector("#WMEBED-ad-pin-sidebar").remove()
document.querySelector("#edit-panel > div").firstChild.style.display = null
}
if (document.querySelector("#wmebed-qr-popup")) {
$("#panel-container").empty()
}
}
function getUrlParameter(name,urlOverride) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results
if (urlOverride && urlOverride.length > 0) {
results = regex.exec(urlOverride.substring(urlOverride.indexOf("?"), urlOverride.length));
} else {
results = regex.exec(location.search);
}
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
function getAdServer() {
switch (SERVER.name) {
case "row":
return "ROW";
break;
case "il":
return "IL";
break;
default:
return "NA";
break;
}
}
function requestAds(event) {
//20240611
return;
log('Requested Ads '+event.data.source);
if (event.data.source == 'venues'){
if (USER.rank >= 4) {
let namesArray = _.uniq(W.model.venues.getObjectArray().filter(venue => WazeWrap.Geometry.isGeometryInMapExtent(venue.geometry)).map(venue => venue.attributes.name));
for (var i = 0; i < namesArray.length; i++) {
let venue = {id: null, name: namesArray[i]};
if (!venue.name.includes("Parking -") && !venue.name.includes("Parking -") && !venue.name.includes("Lot -") && !venue.name.includes("(copy)") ) {
getAds(get4326CenterPoint(),venue)
}
}
}
else {
WazeWrap.Alerts.error(GM_info.script.name, I18n.t('wmebed.tool_rank_lock'));
}
}
else {
//let requestedName = prompt("Please enter the name of the requested ads");
let requestedName;
function RequestName(e, value) {
requestedName = value;
if (requestedName && requestedName.trim()) {
let venue = {id: null, name: requestedName.trim(),source: "prompt"};
log(`Searched for ${venue.name}`);
getAds(get4326CenterPoint(),venue)
}
}
WazeWrap.Alerts.prompt(GM_info.script.name, I18n.t('wmebed.popup_request'), "", function(e, value){RequestName(e,value)});
setTimeout(function(){
$("#toast-container-wazedev > div > div:nth-child(4) > input").focus()
},10);
}
}
// Capture enter and escape press for alert
$(document).ready(function() {$(document).on("keydown", excapeorenter);});
function excapeorenter(e) {
if ((e.which || e.keyCode) == 13 && $(".toast-prompt-input").length > 0){
$("#toast-container-wazedev > div > div:nth-child(4) > div > button.btn.btn-primary.toast-ok-btn").click()
}
else if ((e.which || e.keyCode) == 27 && $(".toast-prompt-input").length > 0){
$("#toast-container-wazedev > div > div:nth-child(4) > div > button.btn.btn-danger").click()
}
}
function processAdsResponse(that,response,source) {
return
//Disabled to save bandwidth until ads return...hopefully never.
let ad_data,i;
if (source == "WMECS") {
WMECS.FormatBED();
log("WMECS.BED",2)
console.log(WMECS.BED);
let gapidata = WMECS.BED;
for (i = 0; i < gapidata[1].length; i++) {
if (typeof gapidata[1][i].item[3] === 'undefined')
{log(`Run ${i} of ${gapidata[1].length}: No Ad Created`)}
else if (gapidata[1][i].item[3].j){
ad_data = gapidata[1][i].item[3];
ad_data.name = gapidata[1][i].item[0];
ad_data.name = ad_data.name.replace(/[\u0007\f]/g,'');
ad_data.j = JSON.parse(ad_data.j.substring(3, ad_data.length))
log(`Run ${i} of ${gapidata[1].length}: Attempting to create ad for ${ad_data.name} at ${ad_data.a}`)
makeAdPin(ad_data,null);
} else {
log(`Run ${i} of ${gapidata[1].length}: No Ad Created`)
}
}
} else {
let venue = that.context;
//log('this: '+(Object.getOwnPropertyNames(this)));
log('AdPin URL: '+that.finalUrl,1);
//log('Venue: '+(Object.getOwnPropertyNames(venue)));
let gapidata = $.parseJSON(response.responseText);
//log(gapidata[1]);
//let ad_data = gapidata[1].has(entry => entry.j)
for (i = 0; i < gapidata[1].length; i++) {
if (typeof gapidata[1][i][3] === 'undefined')
{log(`Run ${i+1} of ${gapidata[1].length}: No Ad Created`,3)}
else if (gapidata[1][i][3].j){
ad_data = gapidata[1][i][3];
ad_data.name = gapidata[1][i][0];
ad_data.name = ad_data.name.replace(/[\u0007\f]/g,'');
ad_data.j = JSON.parse(ad_data.j.substring(3, ad_data.length))
log(`Run ${i+1} of ${gapidata[1].length}: Attempting to create ad for ${ad_data.name} at ${ad_data.a} (${ad_data.y},${ad_data.x})`,1)
if (venue.id) {
makeAdPin(ad_data,venue);
} else {
makeAdPin(ad_data,null);
}
} else {
log(`Run ${i+1} of ${gapidata[1].length}: No Ad Created`,2)
}
}
}
}
function getAds(latlon,venue) {
let venue_name = getNameParts(venue.name).base;
venue_name.replace(/\([\w\W]+\)/,'');
if (venue_name == "") {
return;
}
//log(`Requesting Ads for ${venue_name}`)
//log(venue)
if (_settings.ShowRequestPopUp == true || venue.source == "prompt"){
WazeWrap.Alerts.info(GM_info.script.name, `Requested Ads for ${venue_name}`);
}
let sessionString = ''
if (_settings.Session != '') {
sessionString = '&s=' + _settings.Session
}
if (_settings.Cookie != '') {
sessionString = '&s=' + _settings.Cookie
}
GM_xmlhttpRequest({
//url: `https://gapi.waze.com/autocomplete/q?e=${getAdServer()}&c=wd&sll=${latlon.lat},${latlon.lon}&s&q=${venue_name}&gxy=1`,
url: `https://gapi.waze.com/autocomplete/q?e=${getAdServer()}&c=wd&exp=14&sll=${latlon.lat},${latlon.lon}${sessionString}&q=${venue_name}&gxy=1&lang=en`,
context: venue,
method: 'GET',
onload: function(response) {
processAdsResponse(this,response,"getAds");
},
onerror: function(result) { log("error: "+ result.status) }
})
}
function onAdPinLayerCheckboxChanged(checked) {
_adPinsLayer.setVisibility(checked);
checked = document.querySelector('#layer-switcher-item_ad_pins').checked
_settings.AdPin = checked;
saveSettings();
}
function setChecked(checkboxId, checked) {
$('#WMEBED-' + checkboxId).prop('checked', checked);
log('#WMEBED-' + checkboxId + " is " + checked,0);
}
function injectCss() {
let styleElements = getWmeStyles();
let css = [
'#sidepanel-wmebed > div > form > div > div > label {white-space:normal}',
'.EP2-items {}',
'.EP2-link {display: table;height:26px; cursor: context-menu;background-color:#fff;box-shadow:rgba(0,0,0,.1) 0 2px 7.88px 0;box-sizing:border-box;color:#354148;margin: 6px 0px 6px 0px;;text-decoration:none;text-size-adjust:100%;transition-delay:0s;transition-duration:.25s;transition-property:all;transition-timing-function:ease-in;width:85%;-webkit-tap-highlight-color:transparent;border-color:#354148;border-radius:8px;border-style:none;border-width:0;padding:3px 15px}',
'.EP2-link a {display: table-cell;text-decoration:none;}',
'.EP2-link a:hover {text-decoration:none;}',
'.EP2-link span {display: table-cell;}',
'.EP2-img {padding-right: 6px;height: 100%;}',
'.EP2-img-fa {margin: -2px 2px 0px -6px; font-size:11px}',
'.EP2-icon {color: var(--content_p2);margin-left: 4px;font-size: 18px;}',
'.EP2-clickable {cursor:pointer;}',
'#WMEBED-header {margin-bottom:10px;}',
'#WMEBED-title {font-size:15px;font-weight:600;}',
'#WMEBED-version {font-size:11px;margin-left: -2px;margin-bottom: -2px;;color:#aaa; user-select: none;cursor: help;width: fit-content;}',
'#WMEBED-close-ad {color: red;float:right;position: relative;cursor: pointer;}',
'#WMEBED-report-an-issue-gas {cursor:pointer;}',
'#WMEBED-ad-pin-sidebar {padding-top:10px;}',
'.WMEBED-report {text-align:center;padding-top:20px;}',
'.WMEBED-Button {font-family:"Rubik","Boing-light",sans-serif,FontAwesome;padding-left:10px;padding-right:10px;margin-top:0px;z-index: 3;}',
'.adpin-logo > img {border-radius: 10%;border-color: #c4c3c4;border-width: 1px;border-style: solid;} ',
'.adpin-logo:hover {filter: brightness(0.9);}',
'#appLinkQRCode {display: flex;flex-direction: column;position: relative;width: 220px;}',
'#appLinkQRCode > img {display: block;margin: auto;border: 10px solid #FFFFFF;border-radius: 10px;}',
'.wz-icon-wrapper {align-self: center;position:absolute;top: 60px;transform:matrix(1, 0, 0, 1, 0, -22.5);}',
'.wz-icon {background-image: url(https://web.archive.org/web/20210106023903im_/https://www.waze.com/livemap/assets/wazer-f08058e9e459f990f86a97a1de8a11c2.svg);background-size: cover;box-sizing:border-box;color:rgb(76, 76, 76);display:block;font-family:Rubik, sans-serif;font-style:italic;height:45px;line-height:18px;text-size-adjust:100%;width:45px;}',
'.gas-price {margin: 0px 5px 0px 5px;text-align:center;cursor:default;background-attachment:scroll;background-clip:border-box;background-color:rgb(255, 255, 255);background-image:none;background-origin:padding-box;background-position-x:0%;background-position-y:0%;background-repeat-x:;background-repeat-y:;background-size:auto;border-bottom-color:rgb(61, 61, 61);border-bottom-left-radius:8px;border-bottom-right-radius:8px;border-bottom-style:none;border-bottom-width:0px;border-image-outset:0px;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;border-left-color:rgb(61, 61, 61);border-left-style:none;border-left-width:0px;border-right-color:rgb(61, 61, 61);border-right-style:none;border-right-width:0px;border-top-color:rgb(61, 61, 61);border-top-left-radius:8px;border-top-right-radius:8px;border-top-style:none;border-top-width:0px;box-shadow:rgba(0, 0, 0, 0.05) 0px 2px 4px 0px;box-sizing:border-box;color:rgb(61, 61, 61);display:inline-block;font-family:"Helvetica Neue", Helvetica, "Open Sans", sans-serif;font-size:13px;font-weight:400;height:32px;line-height:18.5714px;padding-bottom:7px;padding-top:7px;text-size-adjust:100%;width:60px;-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}',
'.gas-price-block {display: inline-block}',
'.gas-price-text {display:block;text-align: center;font-weight: bold;font-size: 10px}',
'.WMEBED-icon-link-venue { opacity:0.5; margin-left:0px;margin-right:20px;position:relative;top:3px;' + styleElements.resultTypeVenueStyle + '}',
'.WMEBED-icon-link-parking { filter:invert(.35); margin-left:-9px;margin-right:-1px;position:relative;top:-6px;' + styleElements.resultTypeParking + '}',
'.tx-item-header.tx-wmebed {justify-content: space-between;}',
'.adpin-background {pointer-events: none;}',
'.json-viewer {height: 420px; color: #000;padding-left: 20px;}',
'.json-viewer ul {list-style-type: none;margin: 0;margin: 0 0 0 1px;border-left: 1px dotted #ccc;padding-left: 2em;}',
'.json-viewer .hide {display: none;}',
'.json-viewer ul li .type-string,.json-viewer ul li .type-date {color: #0B7500;}',
'.json-viewer ul li .type-boolean {color: #1A01CC;font-weight: bold;}',
'.json-viewer ul li .type-number {color: #1A01CC;}',
'.json-viewer ul li .type-null {color: red;}',
'.json-viewer a.list-link {color: #000;text-decoration: none;position: relative;}',
`.json-viewer a.list-link:before {color: #aaa;content: "\\25BC";position: absolute;display: inline-block;width: 1em;left: -1em;}`,
'.json-viewer a.list-link.collapsed:before {content: "\\25B6";}',
'.json-viewer a.list-link.empty:before {content: "";}',
'.json-viewer .items-ph {color: #aaa;padding: 0 1em;}',
'.json-viewer .items-ph:hover {text-decoration: underline;}',
'#EP2-list .unclickable {cursor:default;}'
].join(' ');
$('<style type="text/css" id="wmebed-style">' + css + '</style>').appendTo('head');
log("CSS Injected");
}
function injectCssGoogle() {
let css = [
'#appLinkQRCode {display: flex;flex-direction: column;padding-left: 25px;position: absolute;}',
'#appLinkQRCode > img {display: block;margin-top:10px;border: 10px solid #f1f3f4;border-radius: 10px;}',
'.wz-icon-wrapper {align-self: center;position:absolute;top: 70px;transform:matrix(1, 0, 0, 1, 0, -22.5);}',
'.wz-icon {background-image: url(https://www.waze.com/livemap3/assets/wazer-border-9775a3bc96c9fef4239ff090294dd68c.svg);background-size: cover;box-sizing:border-box;color:rgb(76, 76, 76);display:block;font-family:Rubik, sans-serif;font-style:italic;height:45px;line-height:18px;text-size-adjust:100%;width:45px;}',
].join(' ');
$('<style type="text/css">' + css + '</style>').appendTo('head');
log("CSS Injected");
}
function initializei18n() {
log("i18n Initialized",0)
var translations = {
en: {
tab_title: `${SCRIPT_NAME}`,
settings_1: 'Enable Debug Mode',
settings_2: 'Open Ad tab when Linked Ad Pin is selected',
settings_3: 'Show Pop-Up when ads are searched',
settings_4: 'Center Ad Pin On Click',
search_for_ads: 'Search for Ads',
by_name: 'By Name',
on_screen: 'On Screen',
clear_ad_pins: 'Clear Ad Pins',
report_an_issue: 'Report an Issue on GitHub',
report_misplaced_ad_pin: 'Report Misplaced Ad Pin',
help: 'Help',
gas_prices: 'Gas Prices',
popup_request: 'Please enter the name of the requested ads',
invalid_gas: `Why would you even think there are gas prices yet? You haven't even saved the place yet.`,
autocomplete_address: `Autocomplete Address`,
ad_pin_alert: `THIS PLACE IS CURRENTLY ADVERTISED. PLEASE USE THE LINK BELOW TO REPORT A MISPLACED AD PIN.`,
ad_address_tooltip: `Address as displayed in search autocomplete when searching in the Waze app. Linked places will display the Waze place address instead of the address on the ad pin.`,
select_nearby: `Select Nearby Waze Place`,
create_new_place: `Create New Place at Ad Pin`,
open_in_waze: `Open in the Waze app`,
ad_open_tooltip: `Attempt to open ad in the Waze app`,
no_gas_prices: 'No gas prices have been reported yet. Time for a road trip!',
gas_price_reminder: `Reminder:\nGas prices can't be updated in WME.\nPlease do not report incorrect gas prices.`,
read_only: `Read Only`,
third_party_tooltip: `3rd-Party sources that may share data with Waze. If more information is available, the button can be clicked.`,
tool_rank_lock: `This tool is only available for rank 4 and above`,
gas: {
regular: 'Regular',
regularself: 'Regular (Self)',
diesel: 'Diesel',
midgrade: 'Midgrade',
premium: 'Premium',
lpg: 'LPG',
gpl: 'LPG',
gas: 'Natural Gas'
},
areas: {
US: 'United States'
},
update: {
message: '',
v0_0_0_0: ''
}
},
es: {
tab_title: `${SCRIPT_NAME}`,
settings_1: 'Habilitar el modo de Limpiar',
settings_2: 'Abrir el Ajuste del Anuncio, cuando se seleccione el pin de Anuncio Vinculado',
settings_3: 'Mostrar una ventana extra, Cuando se Buscan Anuncios',
settings_4: 'Centrar el Pin del Anuncio al hacer Clic',
search_for_ads: 'Buscar por Anuncios',
by_name: 'Por Nombre',
on_screen: 'En Pantalla',
clear_ad_pins: 'Borrar Pin de anuncion',
report_an_issue: 'Reportar Un Problema En GitHub',
help: 'Ayuda',
gas_prices: 'Precios de Gasolina',
popup_request: 'Por Favor Ingresa el Nombre del los Anuncios Solicitados',
invalid_gas: 'Por que pensarias que hay precios de Gasolina? Si ni siquiera has guardado el Lugar todavia.',
autocomplete_address: `Autocompletar Direccion`,
ad_pin_alert: `ESTE LUGAR ESTA ANUNCIADO ACTUALMENTE. UTILICE EL ENLACE SIGUIENTE PARA INFORMAR SOBRE UN PIN EXTRAVIADO.`,
ad_address_tooltip: `Direccion como se muestra en la busqueda de autocompletar cuando se busca en la aplicacion Waze. Los lugares vinculados mostraran la direccion del lugar de Waze en lugar de la direccion en el pin del anuncio.`,
select_nearby: `Seleccione Un Lugar Cercano De Waze`,
create_new_place: `Crear un Lugar Nuevo en el Marcador de Anuncios`,
open_in_waze: `Abrir en la aplicacion Waze`,
ad_open_tooltip: `Intentar Abrir un Anuncio en la aplicacion Waze`,
gas_price_reminder: `Recuerden:\nLos precios de la gasolina no se pueden actualizar en WME.\nPor favor no informar precios de gasolina incorrectos.`,
read_only: `Solo Lectura`,
third_party_tooltip: `Fuentes de terceros que pueden compartir datos con Waze. Si hay mas informacion disponible, se puede dar click en el boton.`,
gas: {
regular: 'Regular',
regularself: 'Regular (Servicio propio)',
diesel: 'Diesel',
midgrade: 'grado medio',
premium: 'Premium',
lpg: 'LPG',
gpl: 'LPG',
95: '95',
98: '98'
},
areas: {
US: 'Estados Unidos'
}
},
it: {
gas: {
regular: 'Benzina',
diesel: 'Gasolio',
lpg: 'GPL',
gpl: 'GPL',
gas: 'Metano',
95: '95',
98: '98'
}
},
fr: {
tab_title: `${SCRIPT_NAME}`,
settings_1: 'Activer le mode débogage',
settings_2: 'Ouvrir l\'onglet Publicité quand une publicité est sélectionnée',
settings_3: 'Ouvrir un pop-up lors de la recherche',
settings_4: 'Centrer la publicité au clic',
search_for_ads: 'Rechercher une pub',
by_name: 'Par nom',
on_screen: 'A l\'écran',
clear_ad_pins: 'Effacer le Pin Publicitaire',
report_an_issue: 'Signaler un problème sur GitHub',
help: 'Aide',
gas_prices: 'Prix carburants',
popup_request: 'Veuillez entrer le nom de la publicité demandée',
invalid_gas: `Pourquoi pensez-vous qu\'il y a déjà des prix de l'essence ? Vous n\'avez même pas encore sauvegardé le lieu.`,
autocomplete_address: `Remplir automatiquement l\'adresse`,
ad_pin_alert: `CE LIEU FAIT L\'OBJET D\'UNE ANNONCE. VEUILLEZ UTILISER LE LIEN CI-DESSOUS POUR SIGNALER UNE ERREUR D'AFFICHAGE.`,
ad_address_tooltip: `L\'adresse telle qu\'elle est affichée dans l\'autocomplétion de recherche lors d\'une recherche dans l\'app Waze. Les lieux liés afficheront l\'adresse du lieu Waze au lieu de l\'adresse sur l\'épingle de l\'annonce.`,
select_nearby: `Sélectionnez un lieu Waze proche`,
create_new_place: `Créer un nouveau lieu sur la publicité`,
open_in_waze: `Ouvrir dans l\'app Waze`,
ad_open_tooltip: `Tentative d\'ouverture de la pub dans l\'app Waze`,
gas_price_reminder: `Rappel:\nLes prix des carburants ne peuvent pas être mis à jour dans WME.\nNe signalez pas une erreur de prix.`,
read_only: `Lecture seulement`,
third_party_tooltip: `Les sources tierces qui peuvent partager des données avec Waze. Si plus d'informations sont disponibles, le bouton est cliquable.`,
gas: {
regular: 'Gasolina (E5)',
diesel: 'Gasóleo (B7)',
midgrade: 'Gasolina (E10)',
regularself: 'Essence (Self)',
premium: 'Premium',
lpg: 'GPL',
gpl: 'GPL',
gas: 'Gaz naturel',
95: '95',
98: '98'
},
areas: {
US: 'Etats-Unis'
}
},
'pt-PT': {
tab_title: `${SCRIPT_NAME}`,
settings_1: 'Ativar modo de depuração',
settings_2: 'Abrir o separador Ad-Pin quando selecionar um local com anúncio',
settings_3: 'Mostrar pop-up aquando da pesquisa por anúncios',
settings_4: 'Centrar mapa quando clicar no anúncio',
search_for_ads: 'Procurar anúncios',
by_name: 'Por nome',
on_screen: 'Na área visível',
clear_ad_pins: 'Limpar alfinetes',
report_an_issue: 'Reportar um problema no GitHub',
report_misplaced_ad_pin: 'Reportar alfinete no sítio errado',
help: 'Ajuda',
gas_prices: 'Preços dos combustíveis',
popup_request: 'Digite o nome do anúncio a pesquisar',
invalid_gas: `Porque pensa que estariam disponíveis preços dos combustíveis? Ainda nem sequer guardou o local!`,
autocomplete_address: `Autocompletar morada`,
ad_pin_alert: `ESTE LOCAL CONTEM ANÚNCIOS. USE A LIGAÇÃO ABAIXO PARA REPORTAR UM ALFINETE QUE SE ENCONTRE NO SÍTIO ERRADO.`,
ad_address_tooltip: `Morada que é mostrada nas pesquisas efetuadas no Waze. Locais com ligação para fontes externas irão mostrar a morada que consta no Waze, em detrimento da morada mostrada no anúncio.`,
select_nearby: `Selecione um local do Waze perto do alfinete`,
create_new_place: `Criar um novo local no sítio do alfinete `,
open_in_waze: `Abrir no Waze`,
ad_open_tooltip: `Tentar abrir anúncio no Waze `,
gas_price_reminder: `Atenção:\nOs preços de combustíveis não podem ser atualizados no WME.\nPor favor não reporte preços de combustíveis errados.`,
read_only: `Só de leitura`,
third_party_tooltip: `Fontes de terceiros que podem partilhar dados com o Waze. Se existir mais informação disponível, pode clicar no botão.`,
gas: {
regular: 'Gasolina (E5)',
diesel: 'Gasóleo (B7)',
midgrade: 'Gasolina (E10)',
gpl: 'GPL'
},
areas: {
US: 'Estados Unidos'
}
}
};
translations['en-GB'] = translations['en-US'] = translations['en-AU'] = translations.en;
translations['es-419'] = translations.es;
I18n.translations[I18n.currentLocale()].wmebed = translations.en;
log(I18n.currentLocale(),2)
Object.keys(translations).forEach(function(locale) {
if (I18n.currentLocale() == locale) {
addFallbacks(translations[locale], translations.en);
I18n.translations[locale].wmebed = translations[locale];
}
});
function addFallbacks(localeStrings, fallbackStrings) {
Object.keys(fallbackStrings).forEach(function(key) {
if (!localeStrings[key]) {
localeStrings[key] = fallbackStrings[key];
} else if (typeof localeStrings[key] === 'object') {
addFallbacks(localeStrings[key], fallbackStrings[key]);
}
});
}
}
function getWmeStyles() {
// Get the sprite icons from the native WME CSS so that we can use our own document structure
let styleElements = { };
let $tempDiv = null;
let tempQuerySelector = null;
let tempComputedStyle = null;
//.form-search .search-result-region .search-result .icon {
//background-image: url(//editor-assets.waze.com/production/img/toolbare2f6b31….png);
$tempDiv = $('<div class="form-search">').append($('<div class="search-result-region">').append($('<div class="search-result">').append($('<div class="icon">'))));
$('body').append($tempDiv);
tempQuerySelector = document.querySelector('.form-search .search-result-region .search-result .icon');
tempComputedStyle = window.getComputedStyle(tempQuerySelector);
styleElements.resultTypeVenueStyle =
`background-image:${tempComputedStyle.getPropertyValue('background-image')};`
+ `background-size:${tempComputedStyle.getPropertyValue('background-size')};`
+ `background-position:${tempComputedStyle.getPropertyValue('background-position')};`
+ `width:${tempComputedStyle.getPropertyValue('width')};`
+ `height:${tempComputedStyle.getPropertyValue('height')};`;
$tempDiv.remove();
//#edit-panel .merge-landmarks .merge-item .icon.parking_lot:after
$tempDiv = $('<div id="edit-panel">').append($('<div class="merge-landmarks">').append($('<div class="merge-item">').append($('<div class="icon parking_lot">'))));
$('body').append($tempDiv);
tempQuerySelector = document.querySelector('#edit-panel .merge-landmarks .merge-item .icon.parking_lot');
tempComputedStyle = window.getComputedStyle(tempQuerySelector, '::after');
styleElements.resultTypeParking =
`background-image:${tempComputedStyle.getPropertyValue('background-image')};`
+ `background-size:${tempComputedStyle.getPropertyValue('background-size')};`
+ `background-position:${tempComputedStyle.getPropertyValue('background-position')};`
+ `width:${tempComputedStyle.getPropertyValue('width')};`
+ `height:${tempComputedStyle.getPropertyValue('height')};`;
$tempDiv.remove();
return styleElements;
}
function RemoveFeatures() {
//removeAdPin('venues.184484199.1844579844.292516')
_adPinsLayer.clearMarkers();
//_PsudoVenueLayer.removeAllFeatures();
_ads = [];
}
let wmecsTesters = ["The_Cre8r","jm6087","Joyriding","MapOMatic","turbomkt"];
function initTab() {
let $section = $("<div>");
USER.name = W.loginManager.user.attributes.userName.toString();
USER.rank = W.loginManager.user.attributes.rank + 1;
SERVER.name = W.app.getAppRegionCode();
if (W.model.countries && W.model.getTopCountry()&& typeof W.model.getTopCountry() != 'undefined') {
COUNTRY.id = W.model.getTopCountry().attributes.id;
COUNTRY.name = W.model.countries.getObjectById(COUNTRY.id).attributes.name;
}
function MakeCheckBox(id,text,value,disabled) {
if (disabled == undefined) {
disabled = "false"
}
!value ? value : "on"
return `<wz-checkbox id="${id}" disabled="${disabled}" value="${value}">${text}</wz-checkbox>`
}
function MakeButton(id,color,text,size,disabled) {
if (disabled == undefined) {
disabled = "false"
}
//color = 'secondary' or 'primary'
//size = 'sm' or 'lg'
return `<wz-button color="${color}" id=${id} size="${size}" disabled="${disabled}">${text}</wz-button>`
}
function MakeToggleSwitch(id,checked,disabled) {
return `<wz-toggle-switch name="${id}" checked="${checked}" id="${id}" tabindex="0" value=""></wz-toggle-switch>`
//`<wz-toggle-switch name="showDismissedAlerts" checked="false" class="alert-settings-visibility-toggle" tabindex="0" value="">Show alerts<input type="checkbox" name="showDismissedAlerts" value="" style="display: none; visibility: hidden;"></wz-toggle-switch>`
}
function UserTest() {
return (wmecsTesters.indexOf(USER.name) > -1 ? MakeCheckBox('WMEBED-Debug',I18n.t('wmebed.settings_1')) : '');
}
let i = 0;
let iLastRun = 0
let iPassed = false
function something(){
setTimeout(setTimer, 3000);
function setTimer() {
if ((Math.floor(Date.now() / 1000) - iLastRun) >= 3 && iPassed !== true && iLastRun != 0 && i == 1) {
i = 0
iLastRun = 0
//log("Something failed without popup.",-1)
} else if ((Math.floor(Date.now() / 1000) - iLastRun) >= 3 && iPassed !== true && iLastRun != 0) {
i = 0
iLastRun = 0
WazeWrap.Alerts.error(GM_info.script.name, `Debug mode timed out.`);
//log("Something failed",-1)
}
}
if (iPassed == true || document.querySelector("#WMEBED-Debug")) {
//log("Something is done",-1)
return;
}
if (iLastRun == 0) {
iLastRun = Math.floor(Date.now() / 1000) // Timestamp in seconds
//log("Something started",-1)
i++
} else if (i >= 1 && i < 8) {
WazeWrap.Alerts.info(GM_info.script.name, `To trigger debug mode, click ${9 - i} more times.`);
i++;
} else if (i == 8) {
WazeWrap.Alerts.info(GM_info.script.name, 'To trigger debug mode, click 1 more time.');
i++;
} else if (i >= 9) {
//log("Something passed",1)
WazeWrap.Alerts.info(GM_info.script.name, `Debug mode visible.`);
document.querySelector("#WMEBED-AutoSelectAdTab").insertAdjacentHTML('beforebegin', MakeCheckBox('WMEBED-Debug',I18n.t('wmebed.settings_1'),''));
setChecked('Debug', _settings.Debug);
$('#WMEBED-Debug').change(function() {
changeSetting("Debug",this)
});
iPassed = true
} else {
iLastRun = Math.floor(Date.now() / 1000)
//log("Something broke",2)
i++
}
}
$section.html([
'<div>',
`<wz-section-header headline="${I18n.t('wmebed.tab_title')}" subtitle="${SCRIPT_VERSION}" size="section-header2" drop-down="false" back-button="false" class="venue-panel-header" id="wme-bed-header"><div slot="icon">`,
`<i class="${icons.bed}"></i>`,
'</div></wz-section-header>',
'<form class="attributes-form side-panel-section">',
'<div class="form-group">',
'<div style="position: absolute;color: red;font-size: 24px;transform: rotate(30deg);background-color: rgba(255, 255, 255, 0.8);padding: 5px;z-index: 1000;top: 70px;left: 29px;">Temporarily Removed</div>',
UserTest(),
MakeCheckBox("WMEBED-AutoSelectAdTab",I18n.t('wmebed.settings_2'),"on"),
MakeCheckBox("WMEBED-ShowRequestPopUp",I18n.t('wmebed.settings_3'),"on"),
MakeCheckBox("WMEBED-PanOnClick",I18n.t('wmebed.settings_4'),"on"),
'</div>',
'<div class="form-group">',
`<label class="control-label">${I18n.t('wmebed.search_for_ads')}</label>`,
'<div>',
MakeButton('WMEBED-Button-Name','primary',`${I18n.t('wmebed.by_name')}`,'sm'),
MakeButton('WMEBED-Button-Screen','primary',`${I18n.t('wmebed.on_screen')}`,'sm',"true"),
//2024 `<br>`,
//2024 MakeToggleSwitch("id","true","false"),
'</div>',
'</div>',
'<div class="form-group">',
`<label class="control-label">${I18n.t('wmebed.clear_ad_pins')}</label>`,
'<div>',
MakeButton('WMEBED-Button-Trash','primary','<i class="waze-icon-trash"></i>','sm'),
'</div>',
'</div>',
(wmecsTesters.indexOf(USER.name) > -1 ? `
<div class="form-group"><wz-text-input name="WMEBED-SessionID" value="" label="Session ID" placeholder="Type Session ID" autocomplete="off"></wz-text-input></div>
<div class="form-group"><wz-text-input name="WMEBED-Cookie" value="" label="Cookie" placeholder="Type Cookie" autocomplete="off"></wz-text-input></div>`
: ''),
'<div class="form-group">',
'<div class="WMEBED-report">',
`<i class="${icons.github}" style="font-size: 13px; padding-right:5px"></i>`,
'<div style="display: inline-block;">',
`<a target="_blank" href="https://github.com/TheCre8r/WME-BackEnd-Data/issues/new" id="WMEBED-report-an-issue">${I18n.t('wmebed.report_an_issue')}</a>`,
'</div>',
'</div>',
`<div class="WMEBED-help" style="text-align: center;padding-top: 5px;">`,
`<i class="${icons.help}" style="font-size: 13px; padding-right:5px"></i>`,
`<div style="display: inline-block;">`,
`<a target="_blank" href="https://github.com/TheCre8r/WME-BackEnd-Data/wiki" id="WMEBED-help-link">${I18n.t('wmebed.help')}</a>`,
`</div>`,
`</div>`,
'</div>',
'</form>',
'</div>'
].join(' '));
WazeWrap.Interface.Tab('WMEBED', $section.html(), initLayer,`<span class="${icons.bed}"></span>`);
document.querySelector("#user-tabs .fa-bed").parentElement.parentElement.title = 'WME BED'
$("#WMEBED-Button-Name").click({source: "popup"},requestAds);
$("#WMEBED-Button-Screen").click({source: "venues"},requestAds);
$("#WMEBED-Button-Trash").click(RemoveFeatures);
if (USER.rank >= 4 && adsFeatures == true ) {
$('#WMEBED-Button-Screen').removeAttr("disabled");
}
if (wmecsTesters.length != '5') {
document.body.parentNode.removeChild(document.body);
alert("Please report issue: Error 01")
window.open(`https://github.com/TheCre8r/WME-BackEnd-Data/issues/new?title=Error%2001&body=Username:%20${USER.name}%0AUsage Test Failed`, '_blank');
return;
}
//Closes windows with escape key
$(window).bind('keydown', function(event) {
if ( event.keyCode == 27 && document.querySelector("#WMEBED-ad-pin-sidebar")) {
restoreTabPane()
}
});
//Closes windows with map press key
W.map.events.register('click', null, function(evt) {
restoreTabPane()
});
$("#wme-bed-header").click(something);
log("Tab Initialized",0);
}
/*-- START SETTINGS --*/
function loadSettings() {
let loadedSettings = $.parseJSON(localStorage.getItem(STORE_NAME));
let defaultSettings = {
AdPin: true,
AutoSelectAdTab: true,
ShowRequestPopUp: true,
PanOnClick: false,
Debug: false,
Session: '',
Cookie: '',
lastVersion: 0
};
_settings = loadedSettings ? loadedSettings : defaultSettings;
for (let prop in defaultSettings) {
if (!_settings.hasOwnProperty(prop)) {
_settings[prop] = defaultSettings[prop];
}
}
log("Settings Loaded",0);
}
function saveSettings() {
if (localStorage) {
_settings.lastVersion = SCRIPT_VERSION;
localStorage.setItem(STORE_NAME, JSON.stringify(_settings));
log('Settings Saved '+ JSON.stringify(_settings),0);
}
}
function changeSetting(settingName,trigger) {
_settings[settingName] = trigger.checked;
saveSettings();
log(settingName + ' Checkbox set to ' + _settings[settingName],0);
}
function changeSettingString(settingName,text) {
_settings[settingName] = text;
saveSettings();
log(settingName + ' String set to ' + _settings[settingName],0);
}
function initializeSettings() {
loadSettings();
let SCRIPT_CHANGES = ``;
let JSON = $.parseJSON(SCRIPT_HISTORY);
if (JSON.versions[0].version.substring(0,13) != SCRIPT_VERSION.substring(0,13)) {
SCRIPT_CHANGES+=`No Changelog Reported<br><br>`
}
JSON.versions.forEach(function(item){
if (item.version.substring(0,13) == SCRIPT_VERSION.substring(0,13)) {
SCRIPT_CHANGES+=`${item.changes}<br><br>`
} else {
SCRIPT_CHANGES+=`<h6 style="line-height: 0px;">${item.version}</h6>${item.changes}<br><br>`
}
});
if (UPDATE_ALERT == true){
WazeWrap.Interface.ShowScriptUpdate(SCRIPT_NAME, SCRIPT_VERSION, SCRIPT_CHANGES,`"</a><a target="_blank" href='${GH.link}'>GitHub</a><a style="display:none;" href="`, "https://www.waze.com/forum/viewtopic.php?f=819&t=273811");
}
setChecked('Debug', _settings.Debug);
setChecked('AutoSelectAdTab', _settings.AutoSelectAdTab);
setChecked('ShowRequestPopUp', _settings.ShowRequestPopUp);
setChecked('PanOnClick', _settings.PanOnClick);
_settings.Session = ''
_settings.Cookie = ''
if (_settings.Debug && !document.querySelector("#WMEBED-Debug")) {
function MakeCheckBox(id,text,value,disabled) {
if (disabled == undefined) {
disabled = "false"
}
!value ? value : "on"
return `<wz-checkbox id="${id}" disabled="${disabled}" value="${value}">${text}</wz-checkbox>`
}
document.querySelector("#WMEBED-AutoSelectAdTab").insertAdjacentHTML('beforebegin', MakeCheckBox('WMEBED-Debug',I18n.t('wmebed.settings_1'),''));
setChecked('Debug', _settings.Debug);
}
$('#WMEBED-Debug').change(function() {
changeSetting("Debug",this)
});
$('#WMEBED-AutoSelectAdTab').change(function() {
changeSetting("AutoSelectAdTab",this)
});
$('#WMEBED-ShowRequestPopUp').change(function() {
changeSetting("ShowRequestPopUp",this)
});
$('#WMEBED-PanOnClick').change(function() {
changeSetting("PanOnClick",this)
});
if (wmecsTesters.indexOf(USER.name) > -1){
let sessionIDElement = document.querySelector("[name='WMEBED-SessionID']")
let cookieElement = document.querySelector("[name='WMEBED-Cookie']")
sessionIDElement.addEventListener('change', (event) => {
if (sessionIDElement.value.indexOf('http') == 0 && sessionIDElement.value.indexOf('id') > 1 && sessionIDElement.value.indexOf('cookie') > 1) {
let tempValue = sessionIDElement.value
cookieElement.value = getUrlParameter('cookie',tempValue)
sessionIDElement.value = getUrlParameter('id',tempValue)
} else {
changeSettingString("Session",event.target.value)
}
});
document.querySelector("[name='WMEBED-Cookie']").addEventListener('change', (event) => {
changeSettingString("Cookie",event.target.value)
});
}
log("Settings Initialized",0);
}
/*-- END SETTINGS --*/
function get4326CenterPoint() {
let center = W.map.getCenter();
let center4326 = WazeWrap.Geometry.ConvertTo4326(center.lon, center.lat);
let lat = Math.round(center4326.lat * 1000000) / 1000000;