Highlights un-nudged house numbers
目前為
// ==UserScript==
// @name WME Highlight HNs
// @description Highlights un-nudged house numbers
// @version 0.1
// @author SAR85
// @copyright SAR85
// @license CC BY-NC-ND
// @grant none
// @include https://www.waze.com/editor/*
// @include https://www.waze.com/*/editor/*
// @include https://editor-beta.waze.com/*
// @namespace https://greasyfork.org/users/9321
// ==/UserScript==
/***************HN Highlighting***********************/
function highlightUntouched(hnMarkers) {
var i,
n,
marker;
for (i = 0, n = hnMarkers.length; i < n; i++) {
marker = hnMarkers[i];
//marker.model is undefined for a selected HN marker
if ('undefined' !== typeof marker.model &&
null === marker.model.updatedBy) {
marker.icon.$div.find(".drag-handle").css("background-color", "red");
}
}
}
function checkForHN(intervalID) {
var hnMarkers = W.appPresenter.sidebar.editPanel.typeToEditorClass
.segment.houseNumbersControl.markerLayer.markers;
if (hnMarkers.length > 0) {
window.clearInterval(intervalID);
highlightUntouched(hnMarkers);
}
}
function hnInterval() {
var count = 0,
intervalID = window.setInterval(function () {
console.debug('Checking for HN');
//return ++count < 50 ? checkForHN(intervalID) : window.clearInterval(intervalID)
if (++count < 50) {
checkForHN(intervalID);
} else {
window.clearInterval(intervalID);
}
}, 100);
}
function updateAlert() {
var hnVersion = "0.1",
alertOnUpdate = true,
versionChanges = 'WME Highlight HNs has been updated to ' + hnVersion + '.\n';
versionChanges += 'Changes:\n';
versionChanges += '[*]First release.\n';
if (alertOnUpdate && window.localStorage && window.localStorage.hnVersion !== hnVersion) {
window.localStorage.hnVersion = hnVersion;
alert(versionChanges);
}
}
function hnInit() {
updateAlert();
/* Event Listeners for HN Highlighting*/
W.accelerators.events.register('editHouseNumbers', this, hnInterval);
W.model.houseNumbers.events.register('objectschanged', this, hnInterval);
}
function hnBootstrap() {
if ('undefined' !== typeof window.W &&
('undefined' !== typeof W.accelerators) &&
('undefined' !== typeof W.model.houseNumbers)) {
console.log('HN Tool: Initializing...');
window.setTimeout(hnInit, 100);
} else {
console.log('Bootstrap failed. Trying again...');
window.setTimeout(function () {
hnBootstrap();
}, 1000);
}
}
console.log('HN Tool: Bootstrap...');
window.setTimeout(hnBootstrap, 100);