Greasy Fork

Greasy Fork is available in English.

OSM Directions

Replaces the links to GoogleDirections to OpenStreetMap directions

当前为 2025-03-18 提交的版本,查看 最新版本

// ==UserScript==
// @name         OSM Directions
// @namespace    http://technetium.be
// @version      1.0
// @description  Replaces the links to GoogleDirections to OpenStreetMap directions
// @author       Toni Cornelissen ([email protected])
// @match        *://*.geocaching.com/geocache/*
// ==/UserScript==

(function() {
    'use strict';

    function main() {
        const elem = document.getElementById('ctl00_ContentBody_lnkPrintDirectionsSimple');
        if (elem) {
            const orig = elem.href.replace(/.*saddr=/, '').replace(/%20.*/, '');
            const dest = elem.href.replace(/.*daddr=/, '').replace(/%20.*/, '');
            console.warn(orig, dest);
            elem.href = 'https://www.openstreetmap.org/directions?route='+orig+'%3B'+dest;
	}
    }
    main();
})();