Greasemonkey-Skripte
Weiter unten sind die in meiner Firefox-Konfiguration verwendeten und selbst geschriebenen bzw. veränderten Greasemonkey-Skripte aufgeführt.- erweitert/schliesst den Code-Abschnitt.
- markiert den Code-Abschnitt, um ihn bequemer kopieren zu können.
- lädt das Skript herunter bzw. installiert dieses im Firefox.
checkmkwatoshortcuttoservices.user.js
Erstellt ein Icon, mit dem man schnell zur Service-Konfiguration des Hosts gelangt.



// ==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?* // @license CC BY-NC-SA 3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/ // @supportURL https://github.com/ardiman/userscripts/issues // @version 1.0.4 // @date 2014-11-21 // ==/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); } })();
checkmkwatouncheckservice.user.js
Merkt sich, welches Kontrollkästchen immer ein- oder ausgeschaltet sein soll durch Doppelklick auf das Kontrollkästchen unter WATO/Services of host.



// ==UserScript== // @name Check_MK - WATO Uncheck Service // @namespace http://openuserjs.org/users/ardiman // @description Remember which checkbox should be always on or off by doubleclick on checkbox under WATO/Services of host. // @description:de-DE Merkt sich, welches Kontrollkästchen immer ein- oder ausgeschaltet sein soll durch Doppelklick auf das Kontrollkästchen unter WATO/Services of host. // @grant GM_getValue // @grant GM_setValue // @homepage https://github.com/ardiman/userscripts/tree/master/checkmkwatouncheckservice // @icon https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif // @include */check_mk/wato.py?mode=inventory&host* // @include */check_mk/wato.py?filled_in=edithost* // @include */check_mk/wato.py?folder=&host=*&mode=inventory // @license CC BY-NC-SA 3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/ // @supportURL https://github.com/ardiman/userscripts/issues // @version 1.0.4 // @date 2014-11-21 // ==/UserScript== var cmkwatouncheckservice = { setting: { bgru: "blue", // background of table cell with automatically unchecked checkbox bgrc: "purple", // background of table cell with automatically checked checkbox speeks: false, // show alert if "automatically unchecked/checked" is changed }, init: function() { // Select checkboxes var nodes = document.evaluate( "//span[@class='checkbox']/input[@type='checkbox']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); var uncheckedservices = GM_getValue('cmkwatouncheckedservices',''); var checkedservices = GM_getValue('cmkwatocheckedservices',''); var myUArr = uncheckedservices.split(";"); var myCArr = checkedservices.split(";"); var i = 0; // Change style of checkboxes (grandparent) and set their dblclick-event for(var j = 0; j<nodes.snapshotLength; j++) { var thisNode = nodes.snapshotItem(j); var thisNodeName = thisNode.name; var hitU = myUArr.indexOf(thisNodeName); var hitC = myCArr.indexOf(thisNodeName); if (hitU !== -1) { i++; thisNode.checked = false; thisNode.parentNode.parentNode.setAttribute('style','background: ' + cmkwatouncheckservice.setting.bgru + ';'); } if (hitC !== -1) { i++; thisNode.checked = true; thisNode.parentNode.parentNode.setAttribute('style','background: ' + cmkwatouncheckservice.setting.bgrc + ';'); } thisNode.ondblclick=function(event) { event.preventDefault(); event.stopPropagation(); if (this.checked) { cmkwatouncheckservice.changecheck(this,'cmkwatocheckedservices',true,cmkwatouncheckservice.setting.bgrc,'cmkwatouncheckedservices'); } else { cmkwatouncheckservice.changecheck(this,'cmkwatouncheckedservices',false,cmkwatouncheckservice.setting.bgru,'cmkwatocheckedservices'); } }; } return i; }, changecheck: function(ele,whichValue,forMsg,bg,otherValue) { var myServices = GM_getValue(whichValue,''); var otherServices = GM_getValue(otherValue,''); var myArr = myServices.split(";"); var myOtherArr = otherServices.split(";"); var hit = myArr.indexOf(ele.name); var hitOther = myOtherArr.indexOf(ele.name); if (hit === -1) { myServices = myServices + ";" + ele.name; if (cmkwatouncheckservice.setting.speeks) { alert("Next page load will set checked=" + forMsg + " for this input."); } ele.parentNode.parentNode.setAttribute('style','background: ' + bg + ';'); } else { myArr.splice(hit, 1); myServices = myArr.join(';'); if (cmkwatouncheckservice.setting.speeks) { alert("Next page load won't change checked status for this input anymore."); } ele.parentNode.parentNode.setAttribute('style','background: inherit;'); } GM_setValue(whichValue,myServices); if (hitOther !==-1) { myOtherArr.splice(hit, 1); otherServices = myOtherArr.join(';'); GM_setValue(otherValue,otherServices); } } }; var setchkbx = cmkwatouncheckservice.init(); if (cmkwatouncheckservice.setting.speeks && setchkbx !==0) { alert("One or more (" + setchkbx + ") checkboxes were set automatically. Please save this configuration."); }
escape_html_entities.user.js
Per Knopfdruck in Textareas unerwünschte Zeichen ersetzen (momentan spitze Klammern und [kbd]-Tags).



// Copyright 2006 David Wilkinson. All Rights Reserved. // ==UserScript== // @name Escape HTML Entities in TextAreas // @namespace http://www.dopiaza.org/tools/greasemonkey/escapeentities/ // @description Escape HTML Entities in TextAreas // @include * // ==/UserScript== function updateTextAreas() { // Find textareas var textareas = document.evaluate( "//textarea", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < textareas.snapshotLength; i++) { addHandlerLink(textareas.snapshotItem(i)); } } function addHandlerLink(textarea) { var icon = "data:image/png,�PNG IHDR��agAMA��7��tEXtSoftwareAdobe ImageReadyq�e<BIDAT8˥�M��q��{߹w�� �"� ��LH��|m,4Bd�,,��%;�Y�)Y I�X����R�3fL���}���?�s,f��bj�ͳ9�9��'13���ib�������AT Aq"���\ o�A) !�^��O�!j�8�� FP%#���E��bhB`�!De�I�q�X/������ڑQ�e�5c��N\��^���u�8����M56�제%X?��r±�s��H�E��N� J%KpA����z��$�+�������e��)K�Tț�"(�Y(����kdiB�3��"�н��A�7# q!��HZ/��+��Ei4�f$���k�w����V��k�H�v�}��:O���4}fLN��$�.�j��s���s6>Ne�*�wO������ �r��]3�o�'���8��]�9y���/��f�d$[̓'���ƅ�G:[K���*�HB���F5�u�R�u��^��<~������`�S�s�bQ�Z��x���p� `|��HR#�J�z�.�;��-�I�����bh��d�q~ճ�l>:p��űd�7w<�˿�Kv?Q�9�IEND�B`�"; var span = document.createElement('span'); var a = document.createElement('a'); var img = document.createElement('img'); img.setAttribute("src", icon); img.setAttribute("border", "0"); img.setAttribute("alt", "Ersetze <, > und kbd-Tags"); img.setAttribute("title", "Ersetze <, > und kbd-Tags"); img.style.marginLeft = "3px"; a.setAttribute("href", window.location.href+"#"); a.setAttribute("title", "Ersetze <, > und kbd-Tags"); a.appendChild(img); a.addEventListener("click", function(evt) { escapeEntities(textarea); }, false); span.appendChild(a); if (textarea.nextSibling == null) { textarea.parentNode.appendChild(span); } else { textarea.parentNode.insertBefore(span, textarea.nextSibling); } } function escapeEntities(textarea) { var start = textarea.selectionStart; var end = textarea.selectionEnd; var val = textarea.value; var len = val.length; var pos = textarea.scrollTop; var selectionMade = true; if (start == end) { start = 0; end = len; selectionMade = false; } var s = val.slice(start, end); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); //s = s.replace(/&/g, "&"); //s = s.replace(/"/g, """); s = s.replace(/\[KBD\]/gi, "[CODE]"); s = s.replace(/\[\/KBD\]/gi, "[/CODE]"); var pre = val.slice(0, start); var post = val.slice(end, len); textarea.value = pre + s + post; if (selectionMade) { textarea.selectionStart = start; textarea.selectionEnd = start + s.length; } textarea.scrollTop = pos; } window.addEventListener("load", function () { updateTextAreas(); }, false );
fxforumnewtab.user.js
Gepostete Links werden in einem neuen Tab geöffnet.



// ==UserScript== // @name FxForumNewTab // @namespace http://openuserjs.org/users/ardiman // @description Opens posted links in new tabs. // @description:de-DE Öffnet Links in Beiträgen im neuen Tab. // @grant none // @homepage https://github.com/ardiman/userscripts/tree/master/fxforumnewtab // @icon https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif // @include http://www.camp-firefox.de/forum/* // @license CC BY-NC-SA 3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/ // @supportURL https://github.com/ardiman/userscripts/issues // @version 1.0.5 // @date 2014-11-21 // ==/UserScript== var res = document.evaluate("//a[@class='postlink-local']|//a[@class='postlink']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE , null); for(var i = 0; i < res.snapshotLength; i++) { var elem = res.snapshotItem(i); elem.target = "_blank"; }
kennytranslator.user.js
Übersetzt Text in das, was Kenny von South Park sagen würde und zurück. Das Übersetzungsfenster erscheint bei Textmarkierung und auf Klick mit gleichzeitig gehaltener Alt-Taste



// ==UserScript== // @name Kenny Translator // @namespace http://openuserjs.org/users/ardiman // @description Translates text into what Kenny from South Park would say and back again. A translation window appears when you click selected text with the alt key pressed. // @description:de-DE Übersetzt Text in das, was Kenny von South Park sagen würde und umgekehrt. Ein Übersetzungsfenster erscheint, sobald man markierten Text mit gedrückter Alt-Taste anklickt. // @grant none // @homepage https://github.com/ardiman/userscripts/tree/master/kennytranslator // @icon https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif // @exclude http://www.namesuppressed.com/kenny/ // @include * // @license CC BY-NC-SA 3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/ // @supportURL https://github.com/ardiman/userscripts/issues // @version 1.0.3 // @date 2014-11-21 // ==/UserScript== (function () { function kenny_it(text){ kenny=""; for(i=0;i<text.length;i++){ item=text.charAt(i); if((item>="a" && item<="z")||(item>="A" && item<="Z")){ if(item>="a"){ offset=97; }else{ offset=65; } char=((item.charCodeAt(0)-offset).toString(3)); if(char.length<3){ do { char="0"+char; } while (char.length<3); } for(j=0;j<3;j++){ n=char.charAt(j); if(j==0 && offset==65){ kenny=kenny+["M","P","F"][n]; }else{ kenny=kenny+["m","p","f"][n]; } } }else{ kenny=kenny+item; } } return (kenny); } function kenny_said(text){ output=""; upper=false; do{ item=text.charAt(0); n="mpfMPF".indexOf(item); if(n != -1){ if(n>2){ upper=true; n-=3; } for(i=0;i<2;i++){ text=text.substring(1,text.length); char=text.charAt(0); n=n*10+"mpf".indexOf(char); } item=String.fromCharCode(parseInt(n,3)+97); if(upper){ item=item.toUpperCase(); upper=false; } } text=text.substring(1,text.length); output=output+item; }while(text != "") return(output); } var from, to; from = "K"; to = "O"; var defaultTranslation = from + "_" + to; //provides to make visible kenny fish box only when mouse up and alt key pressed //or provides to hide kenny fish box when user click out of box window.addEventListener('mouseup', function(mouseEvent) { var boxLeft = window.kennySpeak.offsetLeft; var boxRight = boxLeft + window.kennySpeak.offsetWidth; var boxTop = window.kennySpeak.offsetTop; var boxBottom = boxTop + window.kennySpeak.offsetHeight; if (window.kennySpeak.style.display == "inline" && (mouseEvent.pageX < boxLeft || mouseEvent.pageX > boxRight || mouseEvent.pageY < boxTop || mouseEvent.pageY > boxBottom)) { window.kennySpeak.stopCapture(); } else if (window.getSelection() != '' && mouseEvent.altKey) { window.kennySpeak.psychicalWavesCapture(mouseEvent, window.getSelection()); } }, true); //create kenny fish object and box instance. make it unvisible on start function engagekennySpeak() { //set global css var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { alert('ugh'); } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = "span.gmkennyTranslatorToolBar {margin: 1px; border: 1px dotted gray; padding: 0px 5px 0px 5px;}"; head.appendChild(style); var kennySpeak = document.createElement("div"); kennySpeak.id = "gmkennySpeak"; kennySpeak.translationFrom = from; kennySpeak.translationTo = to; kennySpeak.fish_imgSrc = "data:image/gif;base64,R0lGODlhEAAQAOe8AHRDIXRFI3VFI3RGJHZGI3dGIndGJHZHI3VHJnpHI3dIJnlIJHZJKH1HInxOLo5KG45LG5VPG5VPHJhQHINXN55RGIhaNqNTGahTFqlUF4deP41fOrBVE7NVEb9UDYlmSrhYFbpYE8JXDb9YEMFaEYtsVctbC71gHM1cDsVgGddcCdZdCNxbBthdCNRfCttcB9ZeCtNgC9xdCN9cBtVhCd1fB99eCOBeBuBeB91gBt1gB9xhB+BgCONfBsFqLN9iCelgBehiBehjBuVlCO1iBfBjBOpmBe9kBaJ8V/BkBO1mBfJkA/NkA/FlBPNkBOtoBvBmBPJlBPNlA/NlBO5oBPJmBPFnBPNmBPJnBPJoBPJoBfNoBfJpA/JpBPNpBPJpB/NpBfJqA/JqBPNqA/NqBPJqB/JrA/JrBPNrA/JrBvJsBvJsCPFtC/JsDvJsD/FuEfJwD+14IOp6J/B7K/J7KvJ+LfKALPKAMbmTbLuUbqyXiPOEMfGFObCZhemRTrKglPOQRvORS/KVTfSWVu2aXvWhZ/SmbPSnb/Wnb/Sob/SocfWpc/WsdPWsdcm7sdu6jsDAw9HFvMjIyuzMn/fJqerRsPLTp+/TvfHat/jaxvzesvzfsfrft/7gsf7hsvnfzf3itvnj0vnj0/nk1Pbn0Pnm1/Ps5/3u1vHw7/Hx8fjy5vjy6Pzy4fry6/vz5fT09fr28Pv49fv49vv59vn6+vr6+vv7+vv7+/z7+vz8/P39/f7+/v///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAP8ALAAAAAAQABAAAAj+AP8JFLjozhs3dRANXPhP0RcsWbBogVjmEMNAWTJq1OLFSxZAAxt16aJlyIgTKWCIMYMGjSGBa7o8qXAAiaVJGx7QQEMmzT9GYqhAGNCHFCdNlSg0cMFlTKI9aEwAKEEr1ypVuRwhuGCEjB04ZjoQ+JMLUqpcklAxmKBDDJs2YDgE0JMrlytcr2o5iJADjRo6W0QI+ACLFahTuSIZyLBjTJxCV15IUJCnUydPmDQUiFFDC6F/ToiowLAAz6ZHFhKEWDFGjMBBS4CwEILCBwgSP1ooCeNn4JwpUWbg8MDDxo0tY+Qs5FNkipQeMqowqRLFiqCBlLRoOXIESpAmUZIHHNFy5tO/gAA7"; kennySpeak.supportedTranslations = { "O_K" : "Text in Kenny", "K_O" : "Kenny in Text" } //hides the kennyspeak box kennySpeak.stopCapture = function() { this.style.display = "none"; } //capture selected text and show the kennyspeak box near the pointer kennySpeak.psychicalWavesCapture = function(mouseEvent, selectedText) { if (this.style.display == "none") { this.style.display = "inline"; this.kennySpeakImage.style.display = "inline"; this.style.left = (mouseEvent.pageX - 20).toString(10) + 'px'; this.style.top = (mouseEvent.pageY - 5).toString(10) + 'px'; this.kennyTextSpan.value = selectedText; } } //translate the code and after set box properties kennySpeak.defecates = function () { this.kennySpeakImage.src = this.fish_imgSrc; if (kennySpeak.translationFrom == "K") { var t= kenny_said(this.kennyTextSpan.value); } else { var t= kenny_it(this.kennyTextSpan.value); } window.kennySpeak.kennyTextSpan.value = t; window.kennySpeak.kennySpeakImage.src = window.kennySpeak.fish_imgSrc; } // kenny fish box style properties kennySpeak.style.border = "1px solid #006699"; kennySpeak.style.display = "none"; kennySpeak.style.position = "absolute"; kennySpeak.style.backgroundColor = "#F4F4F4"; kennySpeak.style.padding = "2px"; kennySpeak.style.MozBorderRadius = "4px"; kennySpeak.style.font = "arial"; kennySpeak.style.fontSize = "12px"; kennySpeak.style.color = "black"; kennySpeak.style.textAlign = "left"; kennySpeak.style.zIndex = "100"; //image button to translate text var kennySpeakImg = document.createElement("img"); kennySpeakImg.src = kennySpeak.fish_imgSrc; kennySpeakImg.title = "Click to translate"; kennySpeakImg.style.border = "none"; kennySpeakImg.style.cursor = "pointer"; kennySpeakImg.style.marginBottom = "-3px"; kennySpeakImg.style.marginLeft = "20px"; kennySpeakImg.addEventListener('click', function() {kennySpeak.defecates();}, true); //text to translate/translated text span var kennyTextSpan = document.createElement("textarea"); kennyTextSpan.cols = "40"; kennyTextSpan.rows = "7"; //close button var closeButton = document.createElement("span"); closeButton.innerHTML = "x"; closeButton.style.cursor = "pointer"; closeButton.className = "gmkennyTranslatorToolBar"; closeButton.title = "Close Kenny Translator"; closeButton.addEventListener('click', function() {kennySpeak.stopCapture();}, true); //translation from and to source var langsSpan = document.createElement("span"); langsSpan.refreshData = function() { langsSpan.innerHTML = kennySpeak.supportedTranslations[kennySpeak.translationFrom + "_" + kennySpeak.translationTo]; langsSpan.title = "Click to change direction"; langsSpan.style.cursor = "pointer"; } langsSpan.className = "gmkennyTranslatorToolBar"; langsSpan.style.cursor = "default"; langsSpan.addEventListener('click', function() { var temp = kennySpeak.translationTo; kennySpeak.translationTo = kennySpeak.translationFrom; kennySpeak.translationFrom = temp; langsSpan.refreshData(); }, true); langsSpan.refreshData(); //toolbar var toolBarDiv = document.createElement("div"); toolBarDiv.style.borderBottom = "1px solid #cccccc"; toolBarDiv.style.margin = "2px 0px"; toolBarDiv.style.paddingBottom = "2px"; //append objects to toolbar toolBarDiv.appendChild(closeButton); toolBarDiv.appendChild(langsSpan); toolBarDiv.appendChild(kennySpeakImg); //put html objects into kennyspeak box kennySpeak.appendChild(toolBarDiv); kennySpeak.appendChild(kennyTextSpan); //set objects into kennyspeak instance kennySpeak.kennySpeakImage = kennySpeakImg kennySpeak.kennyTextSpan = kennyTextSpan; kennySpeak.kennyLangLabel = langsSpan; window.kennySpeak = kennySpeak; document.body.insertBefore(window.kennySpeak, document.body.firstChild); } engagekennySpeak(); })();