-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUR Editor Profile Viewer.js
83 lines (81 loc) · 4.38 KB
/
UR Editor Profile Viewer.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
// ==UserScript==
// @name UR Editor Profile Viewer
// @namespace Dude495
// @version 2020.03.25.01
// @description Changes the editor names in URs to a link direct to the editor profile.
// @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==
// HUGE Thanks to Joyriding & MoM for their patience and helping me learn to the basics and walk me through my first script!!!
(async function() {
'use strict';
var VERSION = GM_info.script.version;
var SCRIPT_NAME = GM_info.script.name;
var UPDATE_ALERT = false;
var UPDATE_NOTES = [
SCRIPT_NAME + ' has been updated to v' + VERSION,
'',
'* WazeWrap version bump.'
].join('\n');
if (UPDATE_ALERT) {
SCRIPT_NAME = SCRIPT_NAME.replace( /\s/g, '') + VERSION;
if (localStorage.getItem(SCRIPT_NAME) !== VERSION) {
alert(UPDATE_NOTES);
localStorage.setItem(SCRIPT_NAME, VERSION);
}
}
function EPV() {
var i;
for (i = 0; i < $('span.username').length; i++) {
if ($('span.username')[i].textContent.includes('(')) {
var epvusername = $('span.username')[i].textContent.match(/(.*)\(\d\)/);
var username = epvusername[1];
var profilelink = '<a href="https://www.waze.com/user/editor/' + username + '" target="_blank">' + epvusername[0] + '</a>';
$('span.username')[i].innerHTML = profilelink;
}
}
}
function PURPM() {
if ($('#panel-container > div > div.place-update > div > div.body > div.scrollable > div > div.add-details > div.small.user')[0].childNodes[1].textContent.includes('(')) {
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;
if ($('#landmark-edit-general > ul > li:nth-child(2)')[0] !== undefined) {
let VenueID = $('#landmark-edit-general > ul > li:nth-child(2)')[0].textContent.match(/([0-9].*)/)[1];
var PermaLink = encodeURIComponent('https://www.waze.com/' + ENVL + '/editor?env=' + ENV + '&lon=' + LON + '&lat=' + LAT + '&zoom=' + ZOOM + '&venues=' + VenueID);
} else {
PermaLink = encodeURIComponent('https://www.waze.com/' + ENVL + '/editor?env=' + ENV + '&lon=' + LON + '&lat=' + LAT + '&zoom=' + ZOOM);
}
var epvusername = $('#panel-container > div > div.place-update > div > div.body > div.scrollable > div > div.add-details > div.small.user')[0].childNodes[1].textContent.match(/(.*)\(\d\)/);
var username = epvusername[1];
var profilelink = ' <a href="https://www.waze.com/forum/ucp.php?i=pm&mode=compose&username=' + username + '&subject=About This Place Update Request&message=[url=' + PermaLink + ']PermaLink[/url] " target="_blank">(PM)</a>';
$('#panel-container > div > div.place-update > div > div.body > div.scrollable > div > div.add-details > div.small.user')[0].innerHTML += profilelink;
};
};
function init() {
var mo = new MutationObserver(mutations => {
mutations.forEach(m => m.addedNodes.forEach(node => {
if ($(node).hasClass('conversation-view') || $(node).hasClass('map-comment-feature-editor')) EPV();
else if ($(node).hasClass('place-update-edit')) PURPM();
}));
});
mo.observe(document.querySelector('#panel-container'), {childList: true, subtree:true});
mo.observe($('#edit-panel .contents')[0], {childList:true, subtree:true});
};
function bootstrap() {
if (W && W.loginManager && W.loginManager.user && ($('#panel-container').length || $('span.username').length >= 1)) {
init();
console.log(GM_info.script.name, 'Initialized');
} else {
console.log(GM_info.script.name, 'Bootstrap failed. Trying again...');
window.setTimeout(() => bootstrap(), 500);
}
}
bootstrap();
})();