WME Color Highlights City ß

Adds colours to road segments to show their status

目前為 2014-06-15 提交的版本,檢視 最新版本

// ==UserScript==
// @name                WME Color Highlights City ß
// @namespace           http://userscripts.org/users/419370
// @description         Adds colours to road segments to show their status
// @resource            HiLiCi.js http://members.aon.at/aneumeister/scripts/waze/hilici2b.user.js
// @resource            version.txt http://members.aon.at/aneumeister/scripts/waze/version.txt
// @include             https://*.waze.com/editor/*
// @include             https://*.waze.com/*/editor/*
// @version             1.9.0.1
// @grant               GM_getResourceURL
// @grant               GM_getResourceText
// @grant               GM_xmlhttpRequest
// ==/UserScript==

/* == meine City-Erweiterung ================================================= */


var aNurl;
var aNstatus;
var aNcnt = 100;

var testGM_TM;
var getURL;
var isCRX = false;

var hilici = new Object();
hilici.CityKnown = new Array();
hilici.CityUnknown = new Array();
hilici.CityInProgress = new Array();
hilici.CityUnknown = [];
hilici.CityKnown = [];
hilici.CityInProgress = [];

testGM_TM = function() {
	try {
		return (typeof GM_getResourceURL === "function");
	}
	catch (err) {
		return false;
	}
};

getURL = function(path) {
	if (isCRX || (!testGM_TM && (window.navigator.vendor.match(/Google/)))) {
		return chrome.extensioVariablesn.getURL(path);
	} else {
		return GM_getResourceURL(path);
	}
};

function _aNchecksCity() {
  var cityName = "";
  var countryName = "";
  var hStr = "";
  var i;

  hilici.CityInProgress	= unsafeWindow.hilici.CityInProgress;
  hilici.CityKnown		= unsafeWindow.hilici.CityKnown;
  hilici.CityUnknown	= unsafeWindow.hilici.CityUnknown;
  console.log("Cities in progress *: " + hilici.CityInProgress.length +
			  " / known : " + hilici.CityKnown.length +
			  " / unknown : " + hilici.CityUnknown.length);

  // Are there any cities?
  if (hilici.CityInProgress.length > 0) {
	var h = hilici.CityInProgress[0].split(",");
	cityName = h[0];
	countryName = h[1];
	console.log("found City: " + cityName + " / Country: " + countryName);
	hStr = '"' + cityName + '"';
	//console.log("WME Highlights: aNchecksCity (aN) ?: " + cityName + ", " + countryName);
	// Search on Web
	aNstatus = undefined;
	aNurl = "http://members.aon.at/aneumeister/scripts/waze/"+countryName+".txt";
	var ret = GM_xmlhttpRequest({
	  method: "GET",
	  url: aNurl,
	  headers: {
	    "Accept": "text/xml"            // If not specified, browser defaults will be used.
	  },
	  //synchronous: true,
	  //timeout: 500,
	  onerror: function(response) {
	  	console.log("WME Highlights: aNchecksCity (aN): " + cityName +" error :/");
	  	i = hilici.CityInProgress.indexOf(cityName+","+countryName);
	  	console.log("WME Highlights: aNchecksCity (aN): i: " + i);
	  	hilici.CityInProgress.splice((i==-1)?0:i,1);
	    },
	  onload: function(response) {
	    console.log(hStr + " Position: " + response.responseText.indexOf(hStr) + " Status: " + response.status);
	    i = hilici.CityInProgress.indexOf(cityName+","+countryName);
	    //console.log("WME Highlights: aNchecksCity (aN): i: " + i);
	    unsafeWindow.hilici.CityInProgress.splice((i==-1)?0:i,1);
	    //alert(hStr + " Position: " + response.responseText.indexOf(hStr) + " Status: " + response.status);

	    // country is missing
	    if (response.status == 404) {
	  	console.log("WME Highlights: aNchecksCity (aN): Country not found: " + countryName);
	  	unsafeWindow.hilici.CityKnown.splice(0, 0, cityName+","+countryName);
	  	return true;
	    }
	    if (response.status != 200) {
	  	console.log("WME Highlights: aNchecksCity (aN): Status: " + response.status);
	  	alert("WME Highlights: aNchecksCity (aN): Status: " + response.status);
	  	return true;
	    }


	    // Search in all cities
	    if (response.responseText.indexOf(hStr) >= 0) {
		  if (unsafeWindow.hilici.CityKnown.indexOf(cityName+","+countryName) == -1) {
	  	    unsafeWindow.hilici.CityKnown.splice(0, 0, cityName+","+countryName); // City found
		  }
	  	  console.log("WME Highlights: aNchecksCity (aN): " + cityName +" found :)");
	  	  return true;
	    } else {
	  	  if (-1 == unsafeWindow.hilici.CityUnknown.indexOf(cityName+","+countryName)) {
		    if (unsafeWindow.hilici.CityUnknown.indexOf(cityName+","+countryName) == -1) {
	  	      alert("Unknown City: " + cityName + " (" + countryName + ")");
	  	      unsafeWindow.hilici.CityUnknown.splice(0, 0, cityName+","+countryName); // Unknown City
		    }
	  	    console.log("WME Highlights: aNchecksCity (aN): " + cityName +" not found :(");
	  	  }
	  	  return false;
	    }
	  }
	  });
  }
  return true;
}

function setNew(){
  var new_version = GM_getResourceText("version.txt");
  unsafeWindow.hilici.new = new_version;
  unsafeWindow.hilici.ldr = "1.9.0.1";
}

var _HiLiCi = document.createElement('script');
_HiLiCi.type = 'text/javascript';
_HiLiCi.text = GM_getResourceText("HiLiCi.js");
_HiLiCi.async = false;
_HiLiCi.onload = function() {
};

document.head.appendChild(_HiLiCi);
window.setInterval(_aNchecksCity, 1601);
window.setTimeout(setNew, 800);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址