-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWME Non-Validated Segments Finder.js
88 lines (86 loc) · 3.66 KB
/
WME Non-Validated Segments Finder.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
// ==UserScript==
// @name WME Non-Validated Segments Finder
// @namespace Dude495
// @version 2019.01.09.03
// @description Identify Non-Verified Segment IDs.
// @author Dude495
// @include /^https:\/\/(www|beta)\.waze\.com\/(?!user\/)(.{2,6}\/)?editor\/?.*$/
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @license GNU GPLv3
// @grant none
// ==/UserScript==
(function() {
'use strict';
function findSegments() {
if (W.map.zoom <= 3) {
alert('Minimum Zoom Lvl 4 Required. Please Zoom In.');
console.error('Minimum Zoom Lvl 4 Required. Please Zoom In.');
}
if (W.map.zoom >= 4) {
var center = W.map.center.clone().transform(W.map.projection.projCode, W.map.displayProjection.projCode);
var LON = center.lon;
var LAT = center.lat;
var ZOOM = W.map.zoom;
var ENVL = $('#sidepanel-prefs > div > div > form > div:nth-child(4) > select')[0].value;
var ENV = $('#env-select > div > select')[0].value;
var SegList = W.model.segments.additionalInfo;
console.log('Scanning ' + SegList.length + ' segments..........')
if (!SegList) {
alert('No Segments Located.');
sessionStorage.setItem('Alert', 'NoS')
};
if (SegList) {
let i;
for (i = 0; i < SegList.length; i++) {
if (SegList[i].attributes.validated == false) {
console.warn('Segment ID ' + SegList[i].attributes.id + ' not verified! PermaLink Below:');
console.log('https://www.waze.com/' + ENVL + '/editor?env=' + ENV + '&lon=' + LON + '&lat=' + LAT + '&zoom=' + ZOOM + '&segments=' + SegList[i].attributes.id);
sessionStorage.setItem('Alert', 'Yes')
sessionStorage.setItem('SegList', SegList[i]);
};
};
console.log('Scan Completed.');
};
if (sessionStorage.getItem('Alert') == 'Yes') {
alert('Non-Verified Segments Found! Please open the Developer Console to view details.')
sessionStorage.removeItem('Alert');
} else if (!sessionStorage.getItem('SegList')) {
alert('No Non-Verified Segments Found.');
sessionStorage.removeItem('Alert');
} else if (sessionStorage.getItem('Alert') == 'NoS') {
alert('No Segments Located, Please move the map to another location and try again.');
sessionStorage.removeItem('Alert');
};
};
};
function init()
{
var $section = $('<div>');
$section.html([
'<div id="NVFS-title">',
'<h3>Non-Validated Segment Finder!</h2>',
'</div>',
].join(' '));
new WazeWrap.Interface.Tab('NVSF', $section.html());
var btn = document.createElement("BUTTON");
btn.id = 'NVFSBtn';
var Button = document.getElementById('NVFSBtn');
btn.textContent = 'Activate';
var Title = document.getElementById('NVFS-title');
Title.after(btn);
btn.onclick = function() { findSegments() }
}
function initializeSettings()
{
}
function bootstrap() {
if (W && W.loginManager && W.loginManager.user) {
init();
console.log(GM_info.script.name, 'Initialized');
} else {
console.log(GM_info.script.name, 'Bootstrap failed. Trying again...');
window.setTimeout(() => bootstrap(), 500);
}
}
bootstrap();
})();