commit b49e3ea92cf07e6e986924f5732976b1193b9113 Author: Luigi D'Acunto Date: Thu Jun 4 12:43:24 2026 +0200 Initial commit diff --git a/checkmk_swissknife.user.js b/checkmk_swissknife.user.js new file mode 100644 index 0000000..8a76782 --- /dev/null +++ b/checkmk_swissknife.user.js @@ -0,0 +1,462 @@ +// ==UserScript== +// @name Checkmk SwissKnife +// @namespace https://monitor.ad.aruba.it/ +// @version 2.0 +// @description Raccolta di miglioramenti all'interfaccia di Checkmk WATO. Ogni fix o enhancement viene aggiunto qui come feature indipendente. +// @author Luigi D'Acunto +// @match *://monitor.ad.aruba.it/*/index.py* +// @match *://monitor.ad.aruba.it/*/wato.py* +// @grant none +// ==/UserScript== + +(function () { + 'use strict'; + + // ========================================================================= + // INFRASTRUTTURA COMUNE + // ========================================================================= + + const LOG_PREFIX = '[CMK-SK]'; + const POLL_INTERVAL_MS = 500; + const MAX_ATTEMPTS = 60; + + // Ricava il documento su cui operare: + // - Se c'è un iframe (index.py con sidebar) → usa il contentDocument dell'iframe + // - Se wato.py è aperto direttamente → usa document solo se contiene la select target + function getWatoDoc(selectId) { + const iframe = document.querySelector('iframe[name="main"], iframe#main'); + if (iframe) { + try { return iframe.contentDocument; } catch (e) { return null; } + } + if (document.getElementById(selectId) || + document.querySelector('select[name*="folder_path"]')) { + return document; + } + return null; + } + + // Inietta CSS nel documento target (una sola volta, deduplica per id) + function injectStyles(iDoc, id, css) { + if (iDoc.getElementById(id)) return; + const style = iDoc.createElement('style'); + style.id = id; + style.textContent = css; + iDoc.head.appendChild(style); + } + + + // ========================================================================= + // FEATURE: Folder Path Select Enhancement + // + // Migliora la