OpenInJosm

Open selected element in Josm

当前为 2020-02-18 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         OpenInJosm
// @namespace    https://github.com/infeeeee/userscripts
// @version      0.1
// @description  Open selected element in Josm
// @author       infeeeee
// @match        *://*.openstreetmap.org/*
// @grant        none
// ==/UserScript==


function openJosm() {
    let id = location.href.match(/www\.openstreetmap\.org\/(relation|node|way)\/(\d+)/);
    console.log(id)
    if (id != null) {
        let obj = id[1].split("")[0]
        window.open('http://127.0.0.1:8111/load_object?objects=' + obj + id[2]);
    } else {
        alert('This script only works on nodes, ways and relations. Please select one!')
    }
}

(function () {
    'use strict';

    const element = document.createElement("button")
    element.innerHTML = "Open in JOSM"

    element.style.cssText = "left: 50%; top: 0px; position: fixed; height: 35px; margin: 10px; padding: 0 0.75rem; border: 1px solid #7ebc6f; border-radius: 3px; background: white; color: #7ebc6f";
    element.style.zIndex = 99999
    element.onclick = function () {
        openJosm()
    }

    document.body.appendChild(element)

})();