OpenInJosm

Open selected element in Josm

Από την 18/02/2020. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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)

})();