User:DarkStarHarry/replaceGeoHack.js

function replaceGeoHack{ var coord_filter = /&params=([\d.+-]+)_([\d.+-]*)_?([\d.+-]*)_?([NS])_([\d.+-]+)_([\d.+-]*)_?([\d.+-]*)_?([EOW])(\b[^&]*)/; var existingMap = "http://toolserver.org/~geohack/geohack.php"; var newMap = "http://maps.google.com/maps?ll={lat},{long}"; var lat,lon; var links = document.getElementsByTagName('A'); var link; for(var i=0; (link=links[i]); i++){ if(link.href.indexOf(existingMap) == 0 && coord_filter.exec(link.href)) { lat=(1.0*RegExp.$1) + ((RegExp.$2||0)/60.0) + ((RegExp.$3||0)/3600.0); if(RegExp.$4=='S') lat*=-1; lon=(1.0*RegExp.$5) + ((RegExp.$6||0)/60.0) + ((RegExp.$7||0)/3600.0); if(RegExp.$8=='W') lon*=-1; link.href=newMap.replace('{lat}', lat).replace('{long}', lon); }	} } addOnloadHook(replaceGeoHack);