Check_MK - WATO Shortcut to services

Generates icon which opens the host's services configuration.

  1. // ==UserScript==
  2. // @name Check_MK - WATO Shortcut to services
  3. // @namespace http://openuserjs.org/users/ardiman
  4. // @description Generates icon which opens the host's services configuration.
  5. // @description:de-DE Erstellt ein Icon, mit dem man schnell zur Service-Konfiguration des Hosts gelangt.
  6. // @grant none
  7. // @homepage https://github.com/ardiman/userscripts/tree/master/checkmkwatoshortcuttoservices
  8. // @icon https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif
  9. // @include *check_mk/view.py?*
  10. // @license CC-BY-NC-SA-3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
  11. // @license MIT; https://opensource.org/licenses/MIT
  12. // @supportURL https://github.com/ardiman/userscripts/issues
  13. // @version 1.0.5
  14. // @date 2017-11-19
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. var nodes = document.evaluate(
  19. "//td[@class='icons']/a[contains(@href,'&mode=edithost')]|//td[@class='tr icons']/a[contains(@href,'&mode=edithost')]",
  20. document,
  21. null,
  22. XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  23. null);
  24.  
  25. for(var i=0; i<nodes.snapshotLength; i++) {
  26. var thisNode = nodes.snapshotItem(i);
  27. var oAnchor = document.createElement("a");
  28. var oImg = oAnchor.appendChild(document.createElement("img"));
  29. oImg.setAttribute('class','icon');
  30. oImg.title = 'Open services of this host in WATO - the Check_MK Web Administration Tool';
  31. oImg.setAttribute('src', 'images/icon_services.png');
  32. oAnchor.href = thisNode.href.replace('&mode=edithost','&mode=inventory');
  33. thisNode.parentNode.insertBefore(oAnchor, thisNode);
  34. }
  35.  
  36. var oWatoDiv = document.getElementById("wato");
  37. if (oWatoDiv !== null) {
  38. var oServDiv = oWatoDiv.cloneNode(true);
  39. oServDiv.id='cb_watoserv';
  40. oServDiv.setAttribute('style','display:none');
  41. oServDiv.firstChild.href = oWatoDiv.firstChild.href.replace('mode=edithost','mode=inventory');
  42. oServDiv.firstChild.firstChild.src = 'images/icon_services.png';
  43. oServDiv.firstChild.firstChild.nextSibling.nodeValue='Services';
  44. oWatoDiv.parentNode.insertBefore(oServDiv, oWatoDiv.nextSibling);
  45. }
  46.  
  47. })();
  48.