Created
July 30, 2011 03:51
-
-
Save 0mg/1115178 to your computer and use it in GitHub Desktop.
google_map_taxi_fare.user.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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