Skip to content

Instantly share code, notes, and snippets.

@0mg
Created July 30, 2011 03:51
Show Gist options
  • Save 0mg/1115178 to your computer and use it in GitHub Desktop.
Save 0mg/1115178 to your computer and use it in GitHub Desktop.
google_map_taxi_fare.user.js
// ==UserScript==
// @name Google Map Taxi Fare
// @include http://www.google.co.jp/maps*
// ==/UserScript==
(function() {
function showFare() {
var routes = document.getElementById("dir_altroutes_body");
if (routes) {
Array.prototype.forEach.call(
routes.getElementsByClassName("altroute-info"),
function(e) {
if ((" " + e.className + " ").indexOf(" fare-shown ") !== -1) {
return;
}
var f = 710;
var d = parseFloat(e.textContent) * 1000;
if (isFinite(d)) {
var t = d - 2000;
if (t > 0) {
f += (t / 288 | 0) * 90;
}
e.textContent += "、" + f + "円";
}
e.className += " fare-shown";
}
);
}
}
showFare();
document.addEventListener("DOMNodeInserted", function(event) {
var e = event.target;
if (e instanceof HTMLElement && e.getElementsByClassName("altroute-info")) {
showFare();
}
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment