OSM Hide Relation Centroid Circle

Hides the orange circle that appears at the centroid of selected relations (e.g. municipality/county borders) on openstreetmap.org

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         OSM Hide Relation Centroid Circle
// @name:sv      OSM – Dölj relations-centroidcirkel
// @namespace    https://greasyfork.org/users/1168708-rotski
// @version      1.0.1
// @description  Hides the orange circle that appears at the centroid of selected relations (e.g. municipality/county borders) on openstreetmap.org
// @description:sv Döljer den orange cirkeln som visas vid centroiden av valda relationer (t.ex. kommun- och länsgränser) på openstreetmap.org
// @author       Rotski + Claude
// @match        https://www.openstreetmap.org/*
// @icon         https://www.openstreetmap.org/favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  var DEFAULT_COLOR = '#FF6200';
  var currentColor = GM_getValue('borderColor', DEFAULT_COLOR);

  function applyStyles() {
    document.querySelectorAll('.leaflet-interactive').forEach(function (el) {
      var stroke = el.getAttribute('stroke') || '';
      var fill = el.getAttribute('fill') || '';
      var d = el.getAttribute('d') || '';
      if (!d) return;
      if (fill === '#FF6200') {
        el.style.display = 'none';
      } else if (stroke === '#FF6200') {
        el.style.stroke = currentColor;
        el.style.fill = 'none';
      }
    });
  }

  // UI
  var ui = document.createElement('div');
  ui.style.cssText = [
    'position:fixed',
    'bottom:20px',
    'right:20px',
    'z-index:99999',
    'background:#fff',
    'border:1px solid #ccc',
    'border-radius:8px',
    'padding:10px 14px',
    'font:13px/1.4 sans-serif',
    'box-shadow:0 2px 8px rgba(0,0,0,0.2)',
    'display:flex',
    'align-items:center',
    'gap:8px'
  ].join(';');

  var label = document.createElement('span');
  label.textContent = 'Gränsfärg:';

  var picker = document.createElement('input');
  picker.type = 'color';
  picker.value = currentColor;
  picker.style.cssText = 'width:36px;height:28px;border:none;padding:0;cursor:pointer;background:none';

  var resetBtn = document.createElement('button');
  resetBtn.textContent = 'Återställ';
  resetBtn.style.cssText = 'font:12px sans-serif;padding:4px 8px;cursor:pointer;border:1px solid #ccc;border-radius:4px;background:#f5f5f5';

  picker.addEventListener('input', function () {
    currentColor = picker.value;
    GM_setValue('borderColor', currentColor);
    applyStyles();
  });

  resetBtn.addEventListener('click', function () {
    currentColor = DEFAULT_COLOR;
    picker.value = DEFAULT_COLOR;
    GM_setValue('borderColor', DEFAULT_COLOR);
    applyStyles();
  });

  ui.appendChild(label);
  ui.appendChild(picker);
  ui.appendChild(resetBtn);
  document.body.appendChild(ui);

  new MutationObserver(applyStyles).observe(document.documentElement, {
    childList: true,
    subtree: true
  });

  applyStyles();
  setTimeout(applyStyles, 500);
  setTimeout(applyStyles, 1500);
})();