greasemonkey/openstreetmap_geouri.user.js
2020-01-28 12:38:02 +01:00

21 lines
932 B
JavaScript

// ==UserScript==
// @name OpenStreetmap
// @namespace https://www.schtobia.de/
// @include https://www.openstreetmap.org/*
// @description OpenStreetmap GeoURI Handler. This resolved "geo:<lat>,<lon>" URIs via openstreetmap, by registering to an unidentified URL on osm and then rewriting it on call.
// @author Tobias Schmidl
// @version 0.1.10
// @grant GM_getValue
// @grant GM_listValues
// @downloadURL https://github.com/schtobia/greasemonkey/raw/master/openstreetmap_geouri.user.js
// @updateURL https://github.com/schtobia/greasemonkey/raw/master/openstreetmap_geouri.user.js
// ==/UserScript==
window.navigator.registerProtocolHandler("geo", "https://www.openstreetmap.org/geouri/%s", GM_info.script.name);
var regex = /geouri\/geo(%3A|:)([0-9\.-]+)(%2C|,)([0-9\.-]+)/;
if (location.href.match(regex))
{
location.href = location.href.replace(regex, "?mlat=$2&mlon=$4&zoom=12");
}