Mefi OSM

Replace Google Maps with OpenStreetMap on Metafilter

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Mefi OSM
// @namespace    exp?zworp!
// @version      0.667
// @description  Replace Google Maps with OpenStreetMap on Metafilter
// @author       farlukar
// @match        https://www.metafilter.com/user/*
// @match        https://irl.metafilter.com/*
// @grant        none
// ==/UserScript==


// link in user profile
if (document.URL.match(/https:\/\/www.metafilter.com\/user\/*/)) {

    let mapLink = document.querySelector("a[title='View on Google Maps']");
    let coordinates = mapLink.href.replace(/.*ll=([^&]*)&.*/,"\$1").split(',');
    mapLink.href = "https://www.openstreetmap.org/?mlat=" + coordinates[0] + "&mlon=" + coordinates[1] + "#map=4/" + coordinates[0] + "/" + coordinates[1];
    mapLink.title = "View on OpenStreetMap";

}


// map in irl
if (document.URL.match(/https:\/\/irl.metafilter.com\/*/)) {

    let address = document.querySelector("div#address a");
    let ll = address.href.split('@');
    let coordinates = ll[1].split(',');
    let lat = Number(coordinates[0]);
    let lon = Number(coordinates[1]);
    let toplat = String(lat + 0.005);
    let bottomlat = String(lat - 0.005);
    let leftlon = String(lon - 0.013);
    let rightlon = String(lon + 0.013);
    lat = String(lat);
    lon = String(lon);
    let showMap = document.getElementById("map");
    showMap.innerHTML = "<iframe width='580' height='200' frameborder='0' scrolling='no' style='margin:0' src='https://www.openstreetmap.org/export/embed.html?bbox=" + leftlon + "," + bottomlat + "," + rightlon +"," + toplat + "&amp;marker=" + lat + "," + lon + "'></iframe>";
    address.href = "https://www.openstreetmap.org/directions?engine=osrm_car&route=;" + lat + "," + lon + "#map=12/" + lat + "/" +lon;

}