Check_MK - WATO Shortcut to services

Generates icon which opens the host's services configuration.

当前为 2014-11-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Check_MK - WATO Shortcut to services
// @namespace    http://openuserjs.org/users/ardiman
// @description  Generates icon which opens the host's services configuration.
// @description:de-DE Erstellt ein Icon, mit dem man schnell zur Service-Konfiguration des Hosts gelangt.
// @grant        none
// @homepage     https://github.com/ardiman/userscripts/tree/master/checkmkwatoshortcuttoservices
// @icon         https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif
// @include      *check_mk/view.py?*
// @version      1.0.3
// @date         2014-11-10
// ==/UserScript==

(function() {
	var nodes = document.evaluate(
		"//td[@class='icons']/a[contains(@href,'&mode=edithost')]|//td[@class='tr icons']/a[contains(@href,'&mode=edithost')]",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);

	for(var i=0; i<nodes.snapshotLength; i++) {
		var thisNode = nodes.snapshotItem(i);
		var oAnchor = document.createElement("a");
		var oImg = oAnchor.appendChild(document.createElement("img"));
		oImg.setAttribute('class','icon');
		oImg.title = 'Open services of this host in WATO - the Check_MK Web Administration Tool';
		oImg.setAttribute('src', 'images/icon_services.png');
		oAnchor.href = thisNode.href.replace('&mode=edithost','&mode=inventory');
		thisNode.parentNode.insertBefore(oAnchor, thisNode);
	}

	var oWatoDiv = document.getElementById("wato");
	if (oWatoDiv !== null) {
		var oServDiv = oWatoDiv.cloneNode(true);
		oServDiv.id='cb_watoserv';
		oServDiv.setAttribute('style','display:none');
		oServDiv.firstChild.href = oWatoDiv.firstChild.href.replace('mode=edithost','mode=inventory');
		oServDiv.firstChild.firstChild.src = 'images/icon_services.png';
		oServDiv.firstChild.firstChild.nextSibling.nodeValue='Services';
		oWatoDiv.parentNode.insertBefore(oServDiv, oWatoDiv.nextSibling);
	}

})();