Verify Waze landmarks linked to Google POI
当前为
// ==UserScript==
// @name WME Google POI verifier
// @name:cs WME Kontrola Google POI
// @version 0.6b
// @description Verify Waze landmarks linked to Google POI
// @description:cs Kontroluje landmarky ve Waze nalinkované na Google POI
// @author Kebb01
// @include https://editor-beta.waze.com/*
// @namespace https://greasyfork.org/cs/scripts/19122-wme-google-poi-verifier
// @grant none
// ==/UserScript==
function readTextFile(file, callback) {
var rawFile = new XMLHttpRequest();
rawFile.overrideMimeType("text/plain");
rawFile.open("GET", file, true);
rawFile.onreadystatechange = function() {
if (rawFile.readyState === 4 && rawFile.status == "200") {
callback(rawFile.responseText);
}
};
rawFile.send(null);
}
// ---
var input=document.createElement("input");
input.type="button";
input.value="Find Google place";
input.onclick = runGPOI;
input.setAttribute("style", "font-size:12px;position:absolute;bottom:70px;left:350px;");
document.body.appendChild(input);
function runGPOI()
{
var gpoiCount = document.getElementsByClassName("select2-chosen");
gpoiCount = gpoiCount.length;
console.log("GPOI: Count of linked Google POIs: " + gpoiCount);
if (gpoiCount < 1) {console.log("GPOI: place is not selected or has no linked Google POI");
alert("GPOI: place is not selected or has no linked Google POI");
} else {
var gpoiToGMaps = window.open('', '_blank');
var gpoi = document.getElementsByClassName('select2-chosen')[0].innerHTML;
console.log("GPOI: used");
console.log("GPOI: " + gpoi + ", " + gpoiCount);
var gpoiPlaceId = document.getElementsByClassName('placeId')[0].innerHTML;
var gpoiData = "https://editor-beta.waze.com/maps/api/place/details/json?placeid=" + gpoiPlaceId + "&key=AIzaSyBIfV0EMXrTDjrvD92QX5bBiyFmBbT-W8E";
readTextFile(gpoiData, function(text){
var data = JSON.parse(text);
var url = (data.result.url);
// url = url + ",_blank";
// function loadUrl(location) {
// this.window.location.href = (location);
// }
// loadUrl(url);
gpoiToGMaps.document.write('Loading Google Maps...');
gpoiToGMaps.location.href = url;
// window.open(url, "_blank");
});
}
}