Zum Inhalt dieser Seite

Greasemonkey-Skripte

Weiter unten sind die in meiner Firefox-Konfiguration verwendeten und selbst geschriebenen bzw. veränderten Greasemonkey-Skripte aufgeführt.
  • Icon für Abschnitt erweitern/schliessen - erweitert/schliesst den Code-Abschnitt.
  • Icon für Markiervorgang - markiert den Code-Abschnitt, um ihn bequemer kopieren zu können.
  • Icon für Download - lädt das Skript herunter bzw. installiert dieses im Firefox.

Nach oben checkmkwatoshortcuttoservices.user.js

Erstellt ein Icon, mit dem man schnell zur Service-Konfiguration des Hosts gelangt.
Abschnitt erweitern/schliessen  Code markieren  Download Dauerhaft aktiviert  Gespiegelt
// ==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);
	}
 
})();
 
 

Nach oben 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.
Abschnitt erweitern/schliessen  Code markieren  Download Dauerhaft aktiviert  Gespiegelt
// ==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.");
}
 
 

Nach oben escape_html_entities.user.js

Per Knopfdruck in Textareas unerwünschte Zeichen ersetzen (momentan spitze Klammern und [kbd]-Tags).
Abschnitt erweitern/schliessen  Code markieren  Download Nur bei Bedarf aktiviert  Gespiegelt
// 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,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%04gAMA%00%00%AF%C87%05%8A%E9%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%02BIDAT8%CB%A5%93M%88%8Dq%14%C6%7F%EF%7B%DF%B9w%A6%99%09%F7%22%1A%9F%09%0B%A5%D8LH%92%AF%7Cm%2C4Bd%81%2C%2C%AC%94%12%25%3B%85%14Y%D9)Y%11%09I%CDX%D8%F9%88%85R%94%193fL%99%B9%EF%7D%EF%FF%FF%3F%FFs%2Cf%C4%C2bj%9E%CD%B39%E79%9D%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9d%AAq~%D5%B3%E8l%3E%3Ap%A2%14%93%C5%B1d%FD%067w%3C%95%CB%BF%01%8FKv%3FQ%979%D3%00%00%00%00IEND%AEB%60%82";
    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, "&lt;");
    s = s.replace(/>/g, "&gt;");
    //s = s.replace(/&/g, "&amp;");
    //s = s.replace(/"/g, "&quot;");
    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
);
 
 

Nach oben fxforumnewtab.user.js

Gepostete Links werden in einem neuen Tab geöffnet.
Abschnitt erweitern/schliessen  Code markieren  Download Dauerhaft aktiviert  Gespiegelt
// ==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";
}
 

Nach oben 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
Abschnitt erweitern/schliessen  Code markieren  Download Nur bei Bedarf aktiviert  Gespiegelt
// ==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%2BBgCONfBsFqLN9iCelgBehiBehjBuVlCO1iBfBjBOpmBe9kBaJ8V%2FBkBO1mBfJkA%2FNkA%2FFlBPNkBOtoBvBmBPJlBPNlA%2FNlBO5oBPJmBPFnBPNmBPJnBPJoBPJoBfNoBfJpA%2FJpBPNpBPJpB%2FNpBfJqA%2FJqBPNqA%2FNqBPJqB%2FJrA%2FJrBPNrA%2FJrBvJsBvJsCPFtC%2FJsDvJsD%2FFuEfJwD%2B14IOp6J%2FB7K%2FJ7KvJ%2BLfKALPKAMbmTbLuUbqyXiPOEMfGFObCZhemRTrKglPOQRvORS%2FKVTfSWVu2aXvWhZ%2FSmbPSnb%2FWnb%2FSob%2FSocfWpc%2FWsdPWsdcm7sdu6jsDAw9HFvMjIyuzMn%2FfJqerRsPLTp%2B%2FTvfHat%2Fjaxvzesvzfsfrft%2F7gsf7hsvnfzf3itvnj0vnj0%2Fnk1Pbn0Pnm1%2FPs5%2F3u1vHw7%2FHx8fjy5vjy6Pzy4fry6%2Fvz5fT09fr28Pv49fv49vv59vn6%2Bvr6%2Bvv7%2Bvv7%2B%2Fz7%2Bvz8%2FP39%2Ff7%2B%2Fv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F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UiFFDC6F%2FToiowLAAz6ZHFhKEWDFGjMBBS4CwEILCBwgSP1ooCeNn4JwpUWbg8MDDxo0tY%2BQs5FNkipQeMqowqRLFiqCBlLRoOXIESpAmUZIHHNFy5tO%2FgAA7";
	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();
 
})();
Home