OpenInJosm

Open selected element in Josm

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

  1. // ==UserScript==
  2. // @name OpenInJosm
  3. // @namespace https://github.com/infeeeee/userscripts
  4. // @version 0.1
  5. // @description Open selected element in Josm
  6. // @author infeeeee
  7. // @match *://*.openstreetmap.org/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. function openJosm() {
  13. let id = location.href.match(/www\.openstreetmap\.org\/(relation|node|way)\/(\d+)/);
  14. console.log(id)
  15. if (id != null) {
  16. let obj = id[1].split("")[0]
  17. window.open('http://127.0.0.1:8111/load_object?objects=' + obj + id[2]);
  18. } else {
  19. alert('This script only works on nodes, ways and relations. Please select one!')
  20. }
  21. }
  22.  
  23. (function () {
  24. 'use strict';
  25.  
  26. const element = document.createElement("button")
  27. element.innerHTML = "Open in JOSM"
  28.  
  29. 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";
  30. element.style.zIndex = 99999
  31. element.onclick = function () {
  32. openJosm()
  33. }
  34.  
  35. document.body.appendChild(element)
  36.  
  37. })();