WME Google POI verifier

Verify Waze landmarks linked to Google POI

当前为 2016-04-30 提交的版本,查看 最新版本

// ==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==

setTimeout(gpoiFunc,999);

function gpoiFunc(){
    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);

                                   gpoiToGMaps.document.write('Loading Google Map...');
                                   gpoiToGMaps.location.href = url;
                               });
                           }
    }
}
//=============== run ==============
gpoiFunc();